Connect Lumi debug chat to the owner Harmony agent
This commit is contained in:
1 parent
17a0cfd9e6
commit
15109142ef
14 files changed
+296
-40
No files matched your search
@@ -2,6 +2,8 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- Use the private Harmony Lumi chat from the owner's Android debug build.
|
||||
|
||||
- Backspace and text corrections work again; recover unfinished practices and backups, add photos reliably and reset break timers after time away.
|
||||
- Switch practices smoothly, pick an astral exercise and claim daily coins; account sync is now called Mesh.
|
||||
- Read Tao Te Ching art on its own page; find Photos and Radio in Apps, with clearer feedback and appearance controls.
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
## [Unreleased]
|
||||
|
||||
- Send private developer turns from the owner's Android debug build.
|
||||
|
||||
- Review complete feedback from the referenced list before one Send or Cancel choice; retries keep the same proposal.
|
||||
|
||||
## [1.5.29] - 2026-11-05
|
||||
|
||||
@@ -237,6 +237,11 @@ LumiRespond :: (input: string) {
|
||||
}
|
||||
AppendLumiChatHost(input, true)
|
||||
tools := ReadLumiToolsHost()
|
||||
prefix := LUMI_DEVELOPER_PREFIX
|
||||
if (tools.available_apps & LUMI_DEVELOPER_CHAT) != 0 &&
|
||||
input.count > prefix.count && input[:prefix.count] == prefix && StartLumiOnlineHost(input) {
|
||||
return
|
||||
}
|
||||
if offered_practice >= 0 {
|
||||
// Lumi asked whether to download or unlock a practice: yes opens
|
||||
// Manage practices at it, no drops it, and anything else is a new request.
|
||||
|
||||
@@ -181,6 +181,18 @@ encrypted records when an account is connected. Online AI agreement is separate
|
||||
from account sync. The wrapper provides input, persistence and bounded
|
||||
app effects; no database pointers or arbitrary code cross the app boundary.
|
||||
|
||||
The owner's Android debug build accepts `/dev MESSAGE` in Lumi while signed in
|
||||
with Inner Breeze online access enabled. Mesh checks the signed session's exact
|
||||
account ID before relaying the message to the private Lumi chat in Harmony.
|
||||
The phone uses a saved turn ID to retry safely and retrieve the reply. It
|
||||
keeps its copy of the developer transcript in the local archive and excludes
|
||||
it from ordinary Lumi model requests, app tool context, and encrypted sync.
|
||||
The private coding workflows live in Harmony.
|
||||
|
||||
The debug host advertises the bridge through Lumi's existing ZX interface.
|
||||
Compatible Lumi package changes use the signed update path described below.
|
||||
Install a new debug APK when the native host itself changes.
|
||||
|
||||
Lumi can open Settings or Appearance, change the app theme with `/theme forest`
|
||||
(or another published theme name), and choose light, dark or system mode.
|
||||
These actions use the same validation, persistence and refresh path as Settings.
|
||||
|
||||
+2
-2
@@ -78,8 +78,8 @@ lumi-feedback-delivery-test: $(ZIRAN_BIN) $(LIBOQS_A) $(SQLITE_SRC) $(SQLITE_AMA
|
||||
# Offline and before the agreement Lumi sends nothing; an own provider gets
|
||||
# its key only in its Authorization header.
|
||||
.PHONY: lumi-connection-test
|
||||
lumi-connection-test: $(ZIRAN_BIN) $(LIBOQS_A) $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H) | build-laws
|
||||
@sh tests/lumi_connection_test.sh $(ZIRAN_BIN) $(LIBOQS_A)
|
||||
lumi-connection-test: $(ZIRAN_BIN) $(LIBOQS_A) $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H) $(AUDIO_OPUS_A) $(AUDIO_MP3_A) $(AUDIO_VORBIS_LIBS) | build-laws
|
||||
@AUDIO_CODECS_BUILD_DIR="$(abspath $(AUDIO_CODECS_BUILD_DIR))" sh tests/lumi_connection_test.sh $(ZIRAN_BIN) $(LIBOQS_A)
|
||||
|
||||
.PHONY: lumi-feedback-list-ui-test
|
||||
lumi-feedback-list-ui-test: $(TARGET) $(INBE_FULL_BUNDLE)
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#import, file "../storage/delegate_store.zi";
|
||||
#import, file "../app/text_buffers.zi";
|
||||
#import, file "package_files.zi";
|
||||
#import, file "lumi_types.zi";
|
||||
|
||||
// Raise when the terms change in substance; everyone agrees again.
|
||||
LUMI_AGREEMENT_VERSION :: 1
|
||||
@@ -283,6 +284,16 @@ LumiNodeTrafficAllowed :: () -> bool {
|
||||
return StoredAccountMode() != AccountModeDelegate && LumiOnlineWanted() && LumiNodeAgreed()
|
||||
}
|
||||
|
||||
LumiDeveloperCommand :: (input: string) -> string {
|
||||
#if #defined(ANDROID_DEBUG) {
|
||||
prefix := LUMI_DEVELOPER_PREFIX
|
||||
if input.count > prefix.count && input[:prefix.count] == prefix {
|
||||
return input[prefix.count:]
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// Agreeing covers the server and, with an own provider, that provider.
|
||||
LumiAgree :: () -> bool {
|
||||
if !LumiRecordNodeAgreement(true) {
|
||||
|
||||
+138
-5
@@ -68,6 +68,13 @@ lumi_online_provider_address: [LUMI_PROVIDER_URL_MAX]u8;
|
||||
lumi_provider_transfer: NetworkTransfer;
|
||||
lumi_provider_status: s32;
|
||||
LUMI_STAGE_PROVIDER :: 4
|
||||
LumiDeveloperPending :: "lumi.private-harmony.pending";
|
||||
lumi_developer_operation: StoredOperation;
|
||||
lumi_developer_session: Session;
|
||||
lumi_developer_transfer: NetworkTransfer;
|
||||
lumi_developer_response: [65536]u8;
|
||||
lumi_developer_owner: [65]u8;
|
||||
lumi_developer_retry: s64;
|
||||
c :: #system_library "c";
|
||||
#if #defined(_WIN32) {
|
||||
OnlineNow :: (out: *s64) -> s64 #foreign c "_time64";
|
||||
@@ -172,13 +179,125 @@ LumiOnlineCancel :: () {
|
||||
lumi_feedback_retry = 0
|
||||
lumi_reply_retry = 0
|
||||
lumi_reply_offset = 0
|
||||
LumiDeveloperCancel()
|
||||
}
|
||||
|
||||
LumiOnlineStart :: (input: string) -> bool {
|
||||
LumiDeveloperCancel :: () {
|
||||
#if #defined(ANDROID_DEBUG) {
|
||||
CancelStoredOperation(*lumi_developer_operation)
|
||||
lumi_developer_session = Session.{}
|
||||
lumi_developer_owner = .{}
|
||||
lumi_developer_retry = 0
|
||||
}
|
||||
}
|
||||
|
||||
LumiDeveloperStart :: (id: string, prompt: string) {
|
||||
if !LumiNodeTrafficAllowed() || storage_has_sync_account() == 0 ||
|
||||
storage_get_setting_text(LumiDeveloperPending).count > 0 {
|
||||
unused LumiAppendRows(LocaleText("lumi_online_unavailable"), false, "", "", true)
|
||||
return
|
||||
}
|
||||
payload: Vec(u8)
|
||||
BuilderPrint(*payload, "{\"id\":\"%\",\"text\":", id)
|
||||
LumiJsonString(*payload, prompt)
|
||||
BuilderPrint(*payload, "}")
|
||||
data := BuilderFinish(payload)
|
||||
defer { PackageFree(data) }
|
||||
storage_set_setting_text(LumiDeveloperPending, data)
|
||||
if storage_setting_text_equals(LumiDeveloperPending, data) == 0 {
|
||||
unused LumiAppendRows(LocaleText("results_write_failed"), false, "", "", true)
|
||||
}
|
||||
}
|
||||
|
||||
LumiDeveloperPump :: () {
|
||||
#if #defined(ANDROID_DEBUG) {
|
||||
owner := AppTextFromCString(storage_user_id_buffer(), 64)
|
||||
if owner != TextUntilNul(lumi_developer_owner[:]) {
|
||||
LumiDeveloperCancel()
|
||||
unused AppCopyText(owner, lumi_developer_owner[:])
|
||||
}
|
||||
pending := storage_get_setting_text(LumiDeveloperPending)
|
||||
if pending.count == 0 {
|
||||
return
|
||||
}
|
||||
if !LumiNodeTrafficAllowed() || storage_has_sync_account() == 0 {
|
||||
LumiDeveloperCancel()
|
||||
return
|
||||
}
|
||||
pending = storage_get_setting_text(LumiDeveloperPending)
|
||||
id_bytes: [33]u8
|
||||
id := ToolString(pending, "id", id_bytes[:])
|
||||
if id.count != 32 {
|
||||
return
|
||||
}
|
||||
now := OnlineNow(null)
|
||||
if lumi_developer_operation.active {
|
||||
if !PollStoredOperation(*lumi_developer_operation) {
|
||||
return
|
||||
}
|
||||
if owner != AppTextFromCString(storage_user_id_buffer(), 64) {
|
||||
LumiDeveloperCancel()
|
||||
return
|
||||
}
|
||||
lumi_developer_session = lumi_developer_operation.session
|
||||
status := lumi_developer_operation.request.status
|
||||
lumi_developer_retry = now + 5
|
||||
if lumi_developer_operation.result == cast(s32)AuthResult.AUTH_OK {
|
||||
document := TextUntilNul(lumi_developer_response[:])
|
||||
receipt: [33]u8
|
||||
if ToolString(document, "id", receipt[:]) != id {
|
||||
return
|
||||
}
|
||||
decoded := ReadStringValue(document, FieldAt(document, 0, "reply"), 8192)
|
||||
reply := BuilderFinish(decoded.value)
|
||||
defer { PackageFree(reply) }
|
||||
if decoded.valid && reply.count > 0 {
|
||||
if LumiAppendRows(reply, false, "", id, true) {
|
||||
storage_set_setting_text(LumiDeveloperPending, "")
|
||||
}
|
||||
} else if FieldAt(document, 0, "reply") < 0 {
|
||||
next: Vec(u8)
|
||||
BuilderPrint(*next, "{\"id\":\"%\"}", id)
|
||||
poll := BuilderFinish(next)
|
||||
storage_set_setting_text(LumiDeveloperPending, poll)
|
||||
PackageFree(poll)
|
||||
}
|
||||
} else if status >= 400 && status < 500 && status != 408 && status != 429 {
|
||||
if LumiAppendRows(LocaleText("lumi_online_unavailable"), false, "", id, true) {
|
||||
storage_set_setting_text(LumiDeveloperPending, "")
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
if now < lumi_developer_retry {
|
||||
return
|
||||
}
|
||||
lumi_developer_retry = now + 5
|
||||
request_body := PackageText(pending, "")
|
||||
defer { PackageFree(request_body) }
|
||||
unused BeginStoredRequest(*lumi_developer_operation, "https://api.waozi.xyz",
|
||||
NetworkTransport(*lumi_developer_transfer), "POST", "/api/v1/lumi/developer",
|
||||
request_body, lumi_developer_response[:], false, *lumi_developer_session)
|
||||
}
|
||||
}
|
||||
|
||||
LumiOnlineStart :: (input: string, local_composer: bool = true) -> bool {
|
||||
if StoredAccountMode() == AccountModeDelegate {
|
||||
LumiOnlineCancel()
|
||||
return false
|
||||
}
|
||||
#if #defined(ANDROID_DEBUG) {
|
||||
developer := ifx local_composer then LumiDeveloperCommand(input) else ""
|
||||
if developer.count > 0 {
|
||||
key := LumiStoreLatestUserKey(input)
|
||||
if LumiDeveloperRecord(key) && key.count >= LumiDeveloperRecordPrefix.count + 32 {
|
||||
LumiDeveloperStart(key[LumiDeveloperRecordPrefix.count:LumiDeveloperRecordPrefix.count + 32], developer)
|
||||
} else {
|
||||
unused LumiAppendRows(LocaleText("results_write_failed"), false, "", "", true)
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
owner := AppTextFromCString(storage_user_id_buffer(), 64)
|
||||
if lumi_online_owner[0] != cast(u8)0 && owner != TextUntilNul(lumi_online_owner[:]) {
|
||||
LumiOnlineCancel()
|
||||
@@ -218,10 +337,15 @@ LumiOnlineStart :: (input: string) -> bool {
|
||||
count := LumiStoreCount()
|
||||
first := count - LUMI_REQUEST_MESSAGE_LIMIT
|
||||
if first < 0 { first = 0 }
|
||||
comma := ""
|
||||
for index: first..count - 1 {
|
||||
if LumiStoreDeveloperRow(index) {
|
||||
continue
|
||||
}
|
||||
row := LumiStoreRow(index)
|
||||
BuilderPrint(*out, "%{\"role\":\"%\",\"content\":",
|
||||
ifx index == first then "" else ",", ifx row.user then "user" else "assistant")
|
||||
comma, ifx row.user then "user" else "assistant")
|
||||
comma = ","
|
||||
if row.developer {
|
||||
// Lumi learns that the developer, not Lumi, wrote this reply, so
|
||||
// the user can answer it.
|
||||
@@ -399,6 +523,10 @@ LumiOnlineAppend :: (reply: string) {
|
||||
// With an id, each part is saved under a record named after it, so every
|
||||
// device that fetches the reply writes the same messages and sync keeps one.
|
||||
LumiOnlineAppendFrom :: (reply: string, developer: bool, quote: string, id: string = "") {
|
||||
unused LumiAppendRows(reply, developer, quote, id, false)
|
||||
}
|
||||
|
||||
LumiAppendRows :: (reply: string, developer: bool, quote: string, id: string, device_local: bool) -> bool {
|
||||
start: s64 = 0
|
||||
part: s32 = 0
|
||||
while start < reply.count {
|
||||
@@ -408,7 +536,7 @@ LumiOnlineAppendFrom :: (reply: string, developer: bool, quote: string, id: stri
|
||||
while end < reply.count && end > start && (reply[end] & cast(u8)192) == cast(u8)128 {
|
||||
end -= 1
|
||||
}
|
||||
if end <= start { return }
|
||||
if end <= start { return false }
|
||||
stable_id := ""
|
||||
if id.count > 0 && lumi_next_message_id.count == 0 {
|
||||
name: Vec(u8)
|
||||
@@ -420,18 +548,22 @@ LumiOnlineAppendFrom :: (reply: string, developer: bool, quote: string, id: stri
|
||||
stable_id = BuilderFinish(name)
|
||||
lumi_next_message_id = stable_id
|
||||
}
|
||||
unused LumiStoreAppendRow(LumiChatRow.{.text = reply[start:end], .developer = developer,
|
||||
.quote = ifx start == 0 then quote else ""})
|
||||
saved := LumiStoreAppendRow(LumiChatRow.{.text = reply[start:end], .developer = developer,
|
||||
.quote = ifx start == 0 then quote else ""}, device_local)
|
||||
if stable_id.count > 0 {
|
||||
lumi_next_message_id = ""
|
||||
PackageFree(stable_id)
|
||||
}
|
||||
if device_local && !saved {
|
||||
return false
|
||||
}
|
||||
start = end
|
||||
part += 1
|
||||
}
|
||||
if lumi_ui.follow_end {
|
||||
lumi_ui.scroll = 1000000
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
LumiOnlineAnswer :: (app: *InnerBreeze) -> bool {
|
||||
@@ -721,6 +853,7 @@ app_lumi_pump :: (app: *InnerBreeze) {
|
||||
return
|
||||
}
|
||||
LumiTelegramPump(app)
|
||||
LumiDeveloperPump()
|
||||
owner := AppTextFromCString(storage_user_id_buffer(), 64)
|
||||
if lumi_online_owner[0] != cast(u8)0 && owner != TextUntilNul(lumi_online_owner[:]) {
|
||||
LumiOnlineCancel()
|
||||
|
||||
+39
-9
@@ -25,6 +25,12 @@ lumi_owner: [64]u8;
|
||||
lumi_store_loaded: bool;
|
||||
lumi_store_error: bool;
|
||||
lumi_store_revision: u64;
|
||||
LumiDeveloperRecordPrefix :: "lumi.private-harmony.message.";
|
||||
|
||||
LumiDeveloperRecord :: (key: string) -> bool {
|
||||
return key.count > LumiDeveloperRecordPrefix.count &&
|
||||
key[:LumiDeveloperRecordPrefix.count] == LumiDeveloperRecordPrefix
|
||||
}
|
||||
|
||||
LumiStoreReset :: () {
|
||||
lumi_store_revision += 1
|
||||
@@ -223,13 +229,16 @@ LumiStoreLoad :: () {
|
||||
LumiStoreRepairReplies(owner)
|
||||
// Deleted messages and the retired donation cards stay out of the chat.
|
||||
statement: *void
|
||||
if SqlitePrepareText(storage_db_handle(), "SELECT value,key FROM (SELECT value,key FROM settings WHERE user_id=?1 AND key LIKE 'cell.lumi.message.%' AND json_extract(value,'$.deleted') IS NULL AND COALESCE(json_extract(value,'$.kind'),0)!=2 ORDER BY CAST(json_extract(value,'$.time') AS INTEGER) DESC,key DESC LIMIT ?2) ORDER BY CAST(json_extract(value,'$.time') AS INTEGER),key", -1, *statement, null) != SQLITE_OK {
|
||||
if SqlitePrepareText(storage_db_handle(), "SELECT value,key FROM (SELECT value,key FROM settings WHERE user_id=?1 AND (key LIKE 'cell.lumi.message.%' OR (?3 AND key LIKE 'lumi.private-harmony.message.%')) AND json_extract(value,'$.deleted') IS NULL AND COALESCE(json_extract(value,'$.kind'),0)!=2 ORDER BY CAST(json_extract(value,'$.time') AS INTEGER) DESC,key DESC LIMIT ?2) ORDER BY CAST(json_extract(value,'$.time') AS INTEGER),key", -1, *statement, null) != SQLITE_OK {
|
||||
lumi_store_error = true
|
||||
return
|
||||
}
|
||||
defer { SqliteFinalize(statement) }
|
||||
bind_text(statement, 1, owner)
|
||||
SqliteBindInt(statement, 2, lumi_history_limit)
|
||||
#if #defined(ANDROID_DEBUG) {
|
||||
SqliteBindInt(statement, 3, 1)
|
||||
}
|
||||
while SqliteStep(statement) == SQLITE_ROW {
|
||||
document := AppTextFromCString(SqliteColumnText(statement, 0), 65536)
|
||||
element: s32 = 0
|
||||
@@ -369,7 +378,7 @@ LumiStoreAppend :: (text: string, user: bool) {
|
||||
|
||||
// The archive key identifies a submitted turn even when its wording repeats.
|
||||
// Callers copy it before later appends or history reloads can change storage.
|
||||
LumiStoreLatestUserKey :: () -> string {
|
||||
LumiStoreLatestUserKey :: (input: string = "") -> string {
|
||||
LumiStoreLoad()
|
||||
if lumi_store_error {
|
||||
return ""
|
||||
@@ -377,7 +386,7 @@ LumiStoreLatestUserKey :: () -> string {
|
||||
index := lumi_count - 1
|
||||
while index >= 0 {
|
||||
if lumi_rows[index].user {
|
||||
return lumi_keys[index]
|
||||
return ifx input.count == 0 || lumi_rows[index].text == input then lumi_keys[index] else ""
|
||||
}
|
||||
index -= 1
|
||||
}
|
||||
@@ -432,7 +441,7 @@ LumiStoreAppendCard :: (text: string, user: bool, kind: s32, payload: string) ->
|
||||
}
|
||||
|
||||
// Saves a message and shows it. Only the developer's text replies quote.
|
||||
LumiStoreAppendRow :: (message: LumiChatRow) -> bool {
|
||||
LumiStoreAppendRow :: (message: LumiChatRow, device_local: bool = false) -> bool {
|
||||
text := message.text
|
||||
user := message.user
|
||||
kind := message.kind
|
||||
@@ -458,10 +467,11 @@ LumiStoreAppendRow :: (message: LumiChatRow) -> bool {
|
||||
nonce: [65]u8
|
||||
if !NativeNonce(null, nonce[:]) { return false }
|
||||
key: string
|
||||
prefix := ifx device_local then LumiDeveloperRecordPrefix else "cell.lumi.message."
|
||||
if lumi_next_message_id.count > 0 {
|
||||
key = PackageText("cell.lumi.message.", lumi_next_message_id)
|
||||
key = PackageText(prefix, lumi_next_message_id)
|
||||
} else {
|
||||
key = PackageText("cell.lumi.message.", TextFromCString(*nonce[0]))
|
||||
key = PackageText(prefix, TextFromCString(*nonce[0]))
|
||||
}
|
||||
defer { PackageFree(key) }
|
||||
out: Vec(u8)
|
||||
@@ -476,7 +486,17 @@ LumiStoreAppendRow :: (message: LumiChatRow) -> bool {
|
||||
BuilderPrint(*out, "}")
|
||||
value := BuilderFinish(out)
|
||||
defer { PackageFree(value) }
|
||||
if !BundledAppRecordWrite(key, value) { return false }
|
||||
if device_local {
|
||||
if storage_get_setting_text(key).count > 0 {
|
||||
return true
|
||||
}
|
||||
storage_set_setting_text(key, value)
|
||||
if storage_setting_text_equals(key, value) == 0 {
|
||||
return false
|
||||
}
|
||||
} else if !BundledAppRecordWrite(key, value) {
|
||||
return false
|
||||
}
|
||||
lumi_next_message_id = ""
|
||||
lumi_storage_revision = storage_data_revision()
|
||||
// Keep the messages already loaded while new replies arrive. Once older
|
||||
@@ -514,7 +534,8 @@ LumiStoreDelete :: (index: s32) -> bool {
|
||||
return false
|
||||
}
|
||||
key := lumi_keys[index]
|
||||
existing := BundledAppRecordRead(key)
|
||||
device_local := LumiDeveloperRecord(key)
|
||||
existing := ifx device_local then PackageText(storage_get_setting_text(key), "") else BundledAppRecordRead(key)
|
||||
defer { PackageFree(existing) }
|
||||
time := ReadNumber(existing, FieldAt(existing, 0, "time"))
|
||||
if !time.valid {
|
||||
@@ -525,13 +546,22 @@ LumiStoreDelete :: (index: s32) -> bool {
|
||||
cast(s64)time.value)
|
||||
value := BuilderFinish(out)
|
||||
defer { PackageFree(value) }
|
||||
if !BundledAppRecordWrite(key, value) {
|
||||
if device_local {
|
||||
storage_set_setting_text(key, value)
|
||||
if storage_setting_text_equals(key, value) == 0 {
|
||||
return false
|
||||
}
|
||||
} else if !BundledAppRecordWrite(key, value) {
|
||||
return false
|
||||
}
|
||||
lumi_storage_revision = -1
|
||||
return true
|
||||
}
|
||||
|
||||
LumiStoreDeveloperRow :: (index: s32) -> bool {
|
||||
return index >= 0 && index < cast(s32)lumi_keys.count && LumiDeveloperRecord(lumi_keys[index])
|
||||
}
|
||||
|
||||
LumiStoreRevision :: () -> u64 {
|
||||
return lumi_store_revision
|
||||
}
|
||||
|
||||
@@ -33,6 +33,8 @@ LUMI_LISTS :: 1
|
||||
LUMI_HABITS :: 2
|
||||
LUMI_PRACTICES :: 4
|
||||
LUMI_DIARY :: 8
|
||||
LUMI_DEVELOPER_CHAT :: 536870912 // Bit 29, outside the app availability bits.
|
||||
LUMI_DEVELOPER_PREFIX :: "/dev "
|
||||
LUMI_INPUT_MAX :: 1024
|
||||
LUMI_CHAT_MAX :: 64
|
||||
// Like Telegram, Lumi opens with this many of the newest messages and adds
|
||||
|
||||
@@ -739,7 +739,7 @@ LumiUiCall :: (context: *void, module: *u8, function: *u8,
|
||||
if name == "StartLumiOnlineHost" && count == 1 &&
|
||||
HostScalarValid(arguments[0], "string", cast(s32)HostString) {
|
||||
input := TextFromBytes(BytesFromPointer(arguments[0].data, cast(u64)arguments[0].length))
|
||||
result.* = HostScalar("bool", ifx LumiOnlineStart(input) then 1 else 0)
|
||||
result.* = HostScalar("bool", ifx LumiOnlineStart(input, lumi_telegram_current == null) then 1 else 0)
|
||||
return 1
|
||||
}
|
||||
if name == "SetLumiOnlineHost" && count == 1 &&
|
||||
@@ -790,6 +790,11 @@ LumiUiCall :: (context: *void, module: *u8, function: *u8,
|
||||
.task_count = lumi_ui.task_count, .habit_count = lumi_ui.habit_count,
|
||||
.choosing_habit = lumi_choosing_habit, .choosing_diary = lumi_choosing_diary,
|
||||
.confirming_delete = LumiDeletePending(), .practices_known = lumi_practice_status != null}
|
||||
#if #defined(ANDROID_DEBUG) {
|
||||
if lumi_telegram_current == null && StoredAccountMode() != AccountModeDelegate {
|
||||
tools.available_apps |= LUMI_DEVELOPER_CHAT
|
||||
}
|
||||
}
|
||||
// Lumi asks to download or unlock a practice before starting it.
|
||||
for practice: cast(s32)0..EXERCISE_COUNT - 1 {
|
||||
if lumi_practice_status == null {
|
||||
@@ -889,7 +894,13 @@ LumiUiCall :: (context: *void, module: *u8, function: *u8,
|
||||
HostScalarValid(arguments[0], "string", cast(s32)HostString) &&
|
||||
HostScalarValid(arguments[1], "bool", cast(s32)HostInteger) {
|
||||
text := TextFromBytes(BytesFromPointer(arguments[0].data, cast(u64)arguments[0].length))
|
||||
LumiStoreAppend(text, arguments[1].integer != 0)
|
||||
user := arguments[1].integer != 0
|
||||
if user && lumi_telegram_current == null && StoredAccountMode() != AccountModeDelegate &&
|
||||
LumiDeveloperCommand(text).count > 0 {
|
||||
unused LumiStoreAppendRow(LumiChatRow.{.text = text, .user = true}, true)
|
||||
} else {
|
||||
LumiStoreAppend(text, user)
|
||||
}
|
||||
return 1
|
||||
}
|
||||
if name == "PerformLumiActionHost" && count == 1 && WidgetValidLumiAction(arguments[0]) {
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#import "drawing_props"
|
||||
#import, file "../src/apps/package_files.zi";
|
||||
#import, file "../src/app/app_types.zi";
|
||||
#import, file "../src/app/app_clock_host.zi";
|
||||
#import, file "../src/app/text_buffers.zi";
|
||||
#import, file "../src/storage/account_types.zi";
|
||||
#import, file "../src/storage/db.zi";
|
||||
@@ -26,7 +27,7 @@
|
||||
#import, file "../src/storage/bundled_app_records.zi";
|
||||
#import, file "../src/storage/sync_async.zi";
|
||||
#import "keys"
|
||||
#import "crypto"
|
||||
#import "mesh_client/crypto"
|
||||
#import, file "../src/storage/sync_account.zi";
|
||||
#import, file "storage_test_support.zi";
|
||||
#import "async_client"
|
||||
@@ -36,7 +37,6 @@
|
||||
#import "transaction"
|
||||
#import, file "../src/apps/catalog.zi";
|
||||
#import "vec"
|
||||
#import "text"
|
||||
#import "byte_text_linux"
|
||||
#import "json_scan"
|
||||
#import, file "../src/apps/app_tools.zi";
|
||||
@@ -44,9 +44,13 @@
|
||||
c :: #system_library "c";
|
||||
TestNow :: (out: *s64) -> s64 #foreign c "time";
|
||||
|
||||
// The full host state exceeds the native test process's stack limit.
|
||||
app: InnerBreeze;
|
||||
owner: AccountKeys;
|
||||
requests: s32;
|
||||
chat_requests: s32;
|
||||
developer_requests: s32;
|
||||
developer_id: [33]u8;
|
||||
provider_requests: s32;
|
||||
feedback_requests: s32;
|
||||
telegram_requests: s32;
|
||||
@@ -128,11 +132,33 @@ ConnectionStart :: (context: *void, request: HttpRequest, output: []u8) -> bool
|
||||
}
|
||||
if request.url == "https://api.waozi.xyz/api/v1/chat/completions" {
|
||||
chat_requests += 1
|
||||
check_true("normal Lumi never sends private Harmony history", !contains(request.body, "private coding fixture"))
|
||||
if continuation_test {
|
||||
return ContinuationReply(request, output)
|
||||
}
|
||||
return AppCopyText("{\"message\":{\"role\":\"assistant\",\"content\":\"Hello from the server\"},\"remaining\":19}", output)
|
||||
}
|
||||
if request.url == "https://api.waozi.xyz/api/v1/lumi/developer" {
|
||||
developer_requests += 1
|
||||
check_true("developer request uses the signed account session", request.token == "synthetic-lumi-token")
|
||||
check_true("developer request sends no Lumi tools or account context",
|
||||
FieldAt(request.body, 0, "context") < 0 && FieldAt(request.body, 0, "tools") < 0)
|
||||
id: [33]u8
|
||||
value := ToolString(request.body, "id", id[:])
|
||||
out: Vec(u8)
|
||||
if developer_requests == 1 {
|
||||
check_true("submit contains just the coding request", contains(request.body, "private coding fixture"))
|
||||
unused AppCopyText(value, developer_id[:])
|
||||
BuilderPrint(*out, "{\"id\":\"%\"}", value)
|
||||
} else {
|
||||
check_true("poll reuses the accepted request id", value == TextUntilNul(developer_id[:]))
|
||||
check_true("poll doesn't resubmit the coding request", FieldAt(request.body, 0, "text") < 0)
|
||||
BuilderPrint(*out, "{\"id\":\"%\",\"reply\":\"Completed private coding fixture\"}", value)
|
||||
}
|
||||
reply := BuilderFinish(out)
|
||||
defer { PackageFree(reply) }
|
||||
return AppCopyText(reply, output)
|
||||
}
|
||||
if request.url == "https://api.waozi.xyz/api/v1/chat/spelling" {
|
||||
spelling_requests += 1
|
||||
return AppCopyText("{\"text\":\"Hello\"}", output)
|
||||
@@ -141,11 +167,11 @@ ConnectionStart :: (context: *void, request: HttpRequest, output: []u8) -> bool
|
||||
icon_requests += 1
|
||||
return AppCopyText("{\"icons\":[\"book\"]}", output)
|
||||
}
|
||||
if ContainsFoldASCII(request.url, "/api/v1/feedback") {
|
||||
if contains(request.url, "/api/v1/feedback") {
|
||||
feedback_requests += 1
|
||||
return AppCopyText("{\"feedback\":[]}", output)
|
||||
}
|
||||
if ContainsFoldASCII(request.url, "/api/v1/lumi/telegram") {
|
||||
if contains(request.url, "/api/v1/lumi/telegram") {
|
||||
telegram_requests += 1
|
||||
return AppCopyText("{\"linked\":false}", output)
|
||||
}
|
||||
@@ -202,6 +228,7 @@ Pump :: (app: *InnerBreeze) {
|
||||
lumi_feedback_retry = 0
|
||||
lumi_reply_retry = 0
|
||||
lumi_telegram_connection.retry = 0
|
||||
lumi_developer_retry = 0
|
||||
app_lumi_pump(app)
|
||||
}
|
||||
}
|
||||
@@ -375,8 +402,6 @@ Check :: () -> s32 {
|
||||
check_true("owner saved", sync_account_save(*owner,
|
||||
cast(SyncAccountLocalDataChoice)SyncAccountLocalDataChoice.SYNC_ACCOUNT_LOCAL_DATA_MERGE) ==
|
||||
cast(SyncAccountSaveResult)SyncAccountSaveResult.SYNC_ACCOUNT_SAVE_OK)
|
||||
app: InnerBreeze
|
||||
|
||||
// Before agreeing, Lumi is offline whatever its switch says: a request
|
||||
// it does not understand gets the offline answer, and a confirmed
|
||||
// feedback report waits. Nothing at all is sent.
|
||||
@@ -408,6 +433,21 @@ Check :: () -> s32 {
|
||||
Pump(*app)
|
||||
check_int("one request to the server's AI", chat_requests, 1)
|
||||
check_true("the server's answer arrives", LastRow() == "Hello from the server")
|
||||
#if #defined(ANDROID_DEBUG) {
|
||||
input := "/dev Review the private coding fixture"
|
||||
check_true("private user request is saved locally", LumiStoreAppendRow(LumiChatRow.{.text = input, .user = true}, true))
|
||||
key := LumiStoreLatestUserKey()
|
||||
check_true("developer record is outside the encrypted app outbox", LumiDeveloperRecord(key) && !BundledAppRecordValid(key))
|
||||
check_true("debug composer starts the developer bridge", LumiOnlineStart(input))
|
||||
Pump(*app)
|
||||
check_int("a developer submission and receipt poll complete", developer_requests, 2)
|
||||
check_true("the matched private response appears", LastRow() == "Completed private coding fixture")
|
||||
check_true("completed turn is no longer pending", storage_get_setting_text(LumiDeveloperPending) == "")
|
||||
LumiStoreReset()
|
||||
check_true("the private result survives reloading the archive", LastRow() == "Completed private coding fixture")
|
||||
} else {
|
||||
check_true("public builds have no developer command", LumiDeveloperCommand("/dev run the fixture") == "")
|
||||
}
|
||||
LumiStoreAppend("Remember the blue notebook", true)
|
||||
for index: cast(s32)0..5 {
|
||||
LumiStoreAppend("An earlier exchange", index % 2 == 0)
|
||||
|
||||
@@ -4,20 +4,21 @@ root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
compiler=${1:-"$root/build/packages/ziran/build/bin/ziran"}
|
||||
liboqs=${2:-"$root/vendor-builds/linux/x86_64/inbe-liboqs/lib/liboqs.a"}
|
||||
work=${3:-"$root/build/lumi-connection-test"}
|
||||
audio_dir=${AUDIO_CODECS_BUILD_DIR:-"$root/vendor-builds/linux/x86_64/audio-codecs"}
|
||||
exec 9>"$work.lock"
|
||||
flock 9
|
||||
unset DISPLAY WAYLAND_DISPLAY XAUTHORITY DBUS_SESSION_BUS_ADDRESS
|
||||
export YUE_DESKTOP_RECOVERY=0
|
||||
mkdir -p "$work/generated"
|
||||
"$compiler" build --target=c --define PLATFORM_DESKTOP --root "$root/tests" \
|
||||
--module-path "$root/src" --module-path "$root/build/packages/kryon/src/ui" \
|
||||
--module-path "$root/build/packages/css/src" $(sh "$root/scripts/package-paths.sh" "$root/build/packages") \
|
||||
--module-path "$root/build/packages/kryon/src/backend" \
|
||||
--module-path "$root/build/packages/game2d/src" \
|
||||
--module-path "$root/build/packages/ziran/std" \
|
||||
--module-path "$root/build/packages/mesh-client" \
|
||||
--entry lumi_connection_behavior:Check -o "$work/generated" \
|
||||
"$root/tests/lumi_connection_behavior.zi" "$root/tests/sync_test_host.zi"
|
||||
set --
|
||||
if [ "${INBE_LUMI_TEST_DEBUG:-0}" = 1 ]; then
|
||||
set -- --define ANDROID_DEBUG
|
||||
fi
|
||||
(cd "$root" &&
|
||||
"$compiler" build --project --offline --target=c --no-main --prune-stale \
|
||||
--define PLATFORM_DESKTOP --define DESKTOP_HOST --define STORAGE_TEST_REAL_HOST_SERVICES "$@" --root "$root" \
|
||||
-o "$work/generated" \
|
||||
"$root/tests/lumi_connection_behavior.zi")
|
||||
cat > "$work/generated/main.c" <<'C'
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
@@ -78,15 +79,18 @@ int main(void)
|
||||
C
|
||||
monocypher="$root/build/packages/monocypher/src"
|
||||
"${CC:-cc}" -std=c11 -O0 -ffunction-sections -fdata-sections \
|
||||
-I"$root/build/packages/ziran/include" -iquote "$work/generated" \
|
||||
-I"$root/build/packages/ziran/include" -iquote "$work/generated" -iquote "$work/generated/tests" \
|
||||
-I"$root/vendor-builds/sqlite" -I"$root/vendor-builds/linux/x86_64/inbe-liboqs/include" \
|
||||
-I"$monocypher" -I"$monocypher/optional" \
|
||||
"$work/generated"/*.c "$root/vendor-builds/sqlite/sqlite3.c" \
|
||||
"$work/generated"/*.c "$work/generated/tests"/*.c "$root/vendor-builds/sqlite/sqlite3.c" \
|
||||
"$monocypher/monocypher.c" "$monocypher/optional/monocypher-ed25519.c" \
|
||||
"$liboqs" -Wl,--gc-sections -Wl,--wrap=network_transport_NetworkTransport \
|
||||
-Wl,--wrap=app_apply_nav_route -Wl,--wrap=practice_actions_app_start_practice \
|
||||
-Wl,--wrap=app_tools_AppToolContext -Wl,--wrap=app_tools_AppToolExecute \
|
||||
-Wl,--wrap=lumi_screen_LumiSubmit \
|
||||
"$audio_dir/libopus/libopus.a" "$audio_dir/libziran_mp3.a" \
|
||||
"$audio_dir/libvorbisfile.a" "$audio_dir/libvorbis.a" "$audio_dir/libogg.a" \
|
||||
$(pkg-config --libs sdl2 cairo pangocairo fontconfig freetype2 gio-2.0 x11) \
|
||||
-ldl -lpthread -lz -lm -o "$work/test"
|
||||
# The provider's key must never reach any output, even with request tracing.
|
||||
mkdir -p /tmp/inbe-lumi-connection-test
|
||||
@@ -100,3 +104,6 @@ if grep -q 'sk-test-lumi-provider' "$work/output.txt"; then
|
||||
fi
|
||||
printf '%s\n' 'Lumi connection: nothing sent before agreeing or offline, diary spelling and habit icons included; server and own provider after agreeing; key only in its header; withdrawal passed'
|
||||
printf '%s\n' 'Lumi conversation: recent history, six tool rounds without replay and complete long UTF-8 replies passed'
|
||||
if [ "${INBE_LUMI_TEST_DEBUG:-0}" = 1 ]; then
|
||||
printf '%s\n' 'Lumi developer chat: signed submit, receipt polling, local archive, and ordinary chat isolation passed'
|
||||
fi
|
||||
@@ -1,6 +1,7 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
||||
cd "$root"
|
||||
work="$root/build/lumi-engine-test"
|
||||
mkdir -p "$work"
|
||||
"$root/build/packages/ziran/build/bin/ziran" bundle --root "$root/tests" \
|
||||
@@ -24,17 +25,15 @@ result=$(env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u DBUS_SESSION_BUS_ADD
|
||||
[ "$result" = 42 ]
|
||||
printf '%s\n' 'Lumi responses: JSON trailing whitespace accepted; malformed and trailing data rejected'
|
||||
printf '%s\n' 'Lumi engine: translated commands, Unicode titles, completion matching and bounded actions passed'
|
||||
"$root/build/packages/ziran/build/bin/ziran" bundle --root "$root/tests" \
|
||||
--module-path "$root/build/packages/kryon/src/ui" \
|
||||
"$root/build/packages/ziran/build/bin/ziran" bundle --project --offline --root "$root/tests" \
|
||||
--entry lumi_message_text_behavior:Answer -o "$work/message-text.zx" \
|
||||
"$root/tests/lumi_message_text_behavior.zi"
|
||||
result=$(env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u DBUS_SESSION_BUS_ADDRESS \
|
||||
"$root/build/packages/ziran/build/bin/ziran" run "$work/message-text.zx")
|
||||
[ "$result" = 42 ]
|
||||
printf '%s\n' 'Lumi emphasis: visible bold ranges, Unicode, escapes, code and literal user messages passed'
|
||||
"$root/build/packages/ziran/build/bin/ziran" bundle --root "$root/tests" \
|
||||
--module-path "$root/build/packages/kryon/src/ui" --define KRYON_HOSTED_UI \
|
||||
$(sh "$root/scripts/package-paths.sh" "$root/build/packages") \
|
||||
"$root/build/packages/ziran/build/bin/ziran" bundle --project --offline --root "$root/tests" \
|
||||
--define KRYON_HOSTED_UI \
|
||||
--entry lumi_reply_cache_behavior:Answer -o "$work/reply-cache.zx" \
|
||||
"$root/tests/lumi_reply_cache_behavior.zi"
|
||||
result=$(env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u DBUS_SESSION_BUS_ADDRESS \
|
||||
|
||||
@@ -75,6 +75,7 @@ asset_entry_at :: (index: usize) -> *EmbeddedAssetEntry {
|
||||
asset_entry_total :: () -> usize {
|
||||
return 1
|
||||
}
|
||||
#if !#defined(STORAGE_TEST_REAL_HOST_SERVICES) {
|
||||
#program_export "app_text_from_cstring"
|
||||
app_text_from_cstring :: (data: *u8, capacity: s32) -> string {
|
||||
if data == null || capacity <= 0 { return "" }
|
||||
@@ -82,6 +83,7 @@ app_text_from_cstring :: (data: *u8, capacity: s32) -> string {
|
||||
while length < capacity && data[length] != cast(u8)0 { length += 1 }
|
||||
return TextFromBytes(BytesFromPointer(data, cast(u64)length))
|
||||
}
|
||||
}
|
||||
|
||||
// File access the account code expects from its host.
|
||||
#program_export "LoadFileText"
|
||||
|
||||
Reference in new issue
Block a user