@mhome/app-facade-protocol 1.154.0 → 1.156.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -44,3 +44,44 @@ calls and prepared commits, in Full and Essential presentation.
44
44
  A partially deleted definition remains available for deletion with the same ID.
45
45
  Existing cleanup steps tolerate resources already removed by an earlier attempt.
46
46
  An already absent and cleaned definition is a completed delete target.
47
+
48
+ ## Single execution control and evidence
49
+
50
+ - `/app/automation/instance/list` takes `{automationId}` and returns
51
+ `{instances: [{threadId, instanceId, revision, phase, startedAt}]}`. Only active
52
+ runs are listed, oldest start first. `phase` is `EXECUTING`, `WAITING`, `QUEUEING`
53
+ or `STOPPING`. Full times are epoch milliseconds; Essential uses Home time.
54
+ - `/app/automation/instance/stop` takes `{automationId, threadId, instanceId}`.
55
+ It fences that instance, captures its execution facts durably, and closes it.
56
+ It leaves other instances and future recurring triggers enabled. The response
57
+ is `{automationId, threadId, instanceId, state, outcome}`. `STOPPING` means the
58
+ executing worker has not completed capture; repeat the same request to observe
59
+ completion. `FINISHED` reports the authoritative terminal outcome. A run that
60
+ completed before the stop request keeps its actual outcome; ordinary success
61
+ may already have discarded its details. Already performed effects are not undone.
62
+ A started external call without a result is uncertain, not a confirmed failure.
63
+ - `/app/automation/diagnostic/get` takes `{automationId}` and lists retained
64
+ execution metadata across all threads, newest first. Bodies are read separately.
65
+ - `/app/automation/diagnostic/read` takes the execution identity and optional
66
+ `cursor`, and returns `{logs, nextCursor}`. Follow the opaque cursor for older
67
+ events. Pages contain up to 100 events with a target size of 256 KiB; a single
68
+ larger event is returned intact. Pagination never removes stored content.
69
+ Missing or damaged bodies produce an error; they are never represented as an
70
+ empty successful page.
71
+
72
+ Events contain `sequence`, `timestamp`, `kind`, `operationId`, `level`, `message`
73
+ and `details`. Ordinary events describe actual action/read requests, their results,
74
+ and scheduled waits. Paired events share an operation ID. Schema-declared sensitive
75
+ request fields are excluded. DEBUG adds internal compiler/interpreter flow. JSONL
76
+ storage uses epoch milliseconds; Essential renders timestamps in Home time without
77
+ changing stored instants. Agent fetches source through the standard source interface;
78
+ execution records never duplicate the original Plan or source.
79
+
80
+ Normal success discards details. Failures/interruption, DEBUG and explicit capture
81
+ retain at most ten instances per thread across revisions. Activity summaries have
82
+ separate retention. Checkpoints persist only new immutable JSONL segments and a
83
+ constant-size head reference, plus runtime memory. An empty segment is not written.
84
+ The Plan is fetched by automation/thread and must match the run's revision; a missing
85
+ or changed Plan ends the old run. Generation and ownership checks still apply.
86
+ A process crash can lose events since its last checkpoint. Explicit stop confirms
87
+ completion only after available evidence has been saved, before checkpoint cleanup.
@@ -50,6 +50,24 @@ ownership, check enabled settings/model/budget, and restrict reads and validatio
50
50
  to that Space. Explicit generation additionally checks the requesting user's
51
51
  Space access. Shape validation cannot substitute for those checks.
52
52
 
53
+ ## Cloud transport
54
+
55
+ The existing authenticated execution envelope has a `suggestion` family with
56
+ `generate`, `read`, `completed`, `failed` and `cancel` messages. Each carries the
57
+ trusted Suggestion invocation and existing dispatch/session binding, without
58
+ inventing a conversation identity. `generate` freezes the collected input, facts
59
+ and model plan. `completed` carries registered result documents, candidate
60
+ failures and measured usage. Input/result JSON remains opaque to the leaf wire
61
+ crate; the shared generator and Space host validate the registered business
62
+ models. Nested transport facts, plans, errors and usage remain strict.
63
+
64
+ Lion authorizes callback reads against the stored active invocation and dispatch,
65
+ then uses existing Facade authorization. Explicit callbacks retain the requesting
66
+ user. Internal scheduled authorization is a separate host integration; recognizing
67
+ its wire shape does not enable periodic generation or grant service authority.
68
+ Terminal delivery is best-effort with bounded execution deadlines, without a
69
+ second durable outbox, reasoning replay or write replay.
70
+
53
71
  ## Generic content and validation
54
72
 
55
73
  `SuggestionDraft<C>` contains title, summary, reasons, evidence, optional expiry,
@@ -102,7 +120,13 @@ The first Automation handler declares `APPLY`: a newly created Automation is
102
120
  saved and enabled; an update preserves the existing Automation's enabled or
103
121
  stopped state within the editing boundary. A deliberately stopped Automation must
104
122
  not be re-enabled by applying an update. UI labels state the resulting action.
105
- Save/enable failure or an unknown outcome is not a completed resolution.
123
+ Handling is one-shot. After an admitted action ends, its Suggestion is `RESOLVED`
124
+ regardless of success, partial success, failure or an unknown write outcome. For
125
+ example, saving the new Automation and failing to enable it records a `partial`
126
+ result with its Automation ID and the enable failure. The UI says what succeeded
127
+ and failed and offers the ordinary Automation entrypoint. It does not leave a
128
+ pending Suggestion, retry button, recovery task or compensation workflow.
129
+ Enabling a new task-flow Automation does not mean executing its task immediately.
106
130
 
107
131
  Other type handlers declare their own actions. The common framework does not
108
132
  equate acceptance with enabling or running a resource. UI opens the already
@@ -134,19 +158,27 @@ unbounded run log, a retry service or catch-up runs for every missed period.
134
158
 
135
159
  ## Suggestion lifecycle and handling
136
160
 
137
- `PENDING` means available for review, `RESOLVED` means the declared type action
138
- completed, `DISMISSED` records rejection, and `EXPIRED` means no longer applicable.
161
+ `PENDING` means available for review, `RESOLVED` means one-shot handling has ended,
162
+ `DISMISSED` records rejection, and `EXPIRED` means no longer applicable.
139
163
  Resolved/dismissed records require a backend resolution. Pending/expired records
140
164
  have none. Resolution records the action, existing operation ID, time, canonical
141
- actor and resulting resource IDs/feedback. `RESOLVED` is not proof that a physical
142
- device reached its target. Failed or unknown outcomes cannot be marked resolved.
165
+ actor, resulting resource IDs/feedback, and the full canonical `FacadeResponse`
166
+ in `result`. Handling lifecycle and business outcome are independent: `RESOLVED`
167
+ is not a success claim or proof that a physical device reached its target.
168
+ An unknown outcome uses the existing error/problem representation, not a new
169
+ status or recovery state. New action handlers always write `result`; older receipts
170
+ without it remain readable and must not be inferred to have succeeded. Summary
171
+ `outcome` projects only the recorded result status, without copying its details.
143
172
 
144
173
  Handling and feedback bind `suggestionId` plus `expectedVersion` to what the
145
174
  user reviewed. Business authorization and existing prepare/commit or idempotency
146
175
  protocols remain authoritative. The backend checks expiry, current resources and
147
- type-specific preconditions before performing the declared action. Repeated
148
- requests retain the same operation identity; unknown outcomes do not justify
149
- unconditional write replay. The model cannot create its own handler or action.
176
+ type-specific preconditions before performing the declared action. An invalid or
177
+ unauthorized request is rejected before admission; it does not consume the
178
+ Suggestion. Once admitted, handling may run at most once. Repeated requests return
179
+ the persisted receipt instead of repeating the business action; an unknown outcome
180
+ does not justify write replay. A host must not claim exactly-once execution across
181
+ an unconfirmed storage failure. The model cannot create its own handler or action.
150
182
 
151
183
  Next-run context includes current facts, pending Suggestions and recent decisions
152
184
  and actual results, plus a bounded summary. Do not append all old prompts forever
@@ -167,14 +199,23 @@ The following are contract declarations, not a current support inventory.
167
199
  | `/app/suggestion/generation/get` | `GenerationGetInput`: optional `runId` | `GenerationGetOutput`: current/latest run, or null before any run |
168
200
  | `/app/suggestion/list` | `ListInput`: type/status filters, cursor, limit (default 50, maximum 100) | `ListOutput`: summaries and optional cursor |
169
201
  | `/app/suggestion/detail/get` | `DetailInput`: `suggestionId` | Complete typed Suggestion |
170
- | `/app/suggestion/handle` | `HandleInput`: ID, expected version, declared action | Updated Suggestion summary on completed success |
202
+ | `/app/suggestion/handle` | `HandleInput`: ID, expected version, declared action | Canonical business result, also stored in the resolution |
171
203
  | `/app/suggestion/feedback` | `FeedbackInput`: ID, expected version, `DISMISS`, optional comment | Updated Suggestion summary on completed success |
204
+ | `/app/suggestion/settings/get` | Empty input | `SuggestionSettings` |
205
+ | `/app/suggestion/settings/save` | `SuggestionSettings`: explicit `enabled` boolean | Saved `SuggestionSettings` |
172
206
 
173
207
  An explicit unknown or no-longer-retained run ID returns `NOT_FOUND`; it must not
174
208
  silently return an unrelated run. Lists are bounded and omit script bundles,
175
209
  evidence and resolutions; detail reads return the saved complete content.
176
- Business errors/partial or unknown outcomes use the canonical Facade result and
177
- must not be converted to a successful lifecycle transition.
210
+ Business errors/partial or unknown outcomes use the canonical Facade result;
211
+ marking handling finished must not replace that result with `success`.
212
+
213
+ Settings belong to the authorized Space. Absent storage defaults to `enabled: true`.
214
+ The switch controls periodic generation only; explicit authorized generation remains
215
+ available. The UI places it in the existing Agent Settings page. Turning it off
216
+ prevents future periodic admissions; it does not delete results or replay/cancel
217
+ an admitted run. Settings follow the Space migration/deletion boundary. This adds
218
+ no per-Suggestion timer, follow-up task or separate scheduler per output type.
178
219
 
179
220
  ## Conformance
180
221
 
@@ -342,11 +342,9 @@
342
342
  "threadId": 0,
343
343
  "instanceId": "run",
344
344
  "timestamp": 100,
345
- "status": "failed",
345
+ "status": "FAILED",
346
346
  "reportMode": "STD",
347
347
  "logCount": 2,
348
- "omittedLogs": 1,
349
- "truncated": true,
350
348
  "logsMissing": false,
351
349
  "failure": {
352
350
  "message": "device unavailable",
@@ -355,18 +353,7 @@
355
353
  "revision": 3,
356
354
  "startedAt": 90,
357
355
  "finishedAt": 100,
358
- "logs": [
359
- {
360
- "level": "INFO",
361
- "message": "Invoked device",
362
- "timestamp": 100
363
- },
364
- {
365
- "level": "ERROR",
366
- "message": "Timed out",
367
- "timestamp": 100
368
- }
369
- ]
356
+ "captured": false
370
357
  }
371
358
  ]
372
359
  },
@@ -378,11 +365,9 @@
378
365
  "threadId": 0,
379
366
  "instanceId": "run",
380
367
  "timestamp": "1970-01-01 00:00:00.100 +00:00 (UTC)",
381
- "status": "failed",
368
+ "status": "FAILED",
382
369
  "reportMode": "STD",
383
370
  "logCount": 2,
384
- "omittedLogs": 1,
385
- "truncated": true,
386
371
  "logsMissing": false,
387
372
  "failure": {
388
373
  "message": "device unavailable",
@@ -391,18 +376,7 @@
391
376
  "revision": 3,
392
377
  "startedAt": "1970-01-01 00:00:00.090 +00:00 (UTC)",
393
378
  "finishedAt": "1970-01-01 00:00:00.100 +00:00 (UTC)",
394
- "logs": [
395
- {
396
- "level": "INFO",
397
- "message": "Invoked device",
398
- "timestamp": "1970-01-01 00:00:00.100 +00:00 (UTC)"
399
- },
400
- {
401
- "level": "ERROR",
402
- "message": "Timed out",
403
- "timestamp": "1970-01-01 00:00:00.100 +00:00 (UTC)"
404
- }
405
- ]
379
+ "captured": false
406
380
  }
407
381
  ]
408
382
  }
@@ -5041,5 +5015,73 @@
5041
5015
  }
5042
5016
  },
5043
5017
  "code": "OPERATION_FAILED"
5018
+ },
5019
+ {
5020
+ "name": "automation-diagnostic-read",
5021
+ "target": "/app/automation/diagnostic/read",
5022
+ "timezone": "Asia/Shanghai",
5023
+ "status": "success",
5024
+ "data": {
5025
+ "logs": [
5026
+ {
5027
+ "sequence": 1,
5028
+ "kind": "wait.started",
5029
+ "operationId": "visit-1",
5030
+ "level": "INFO",
5031
+ "message": "Waiting",
5032
+ "timestamp": 100,
5033
+ "details": {
5034
+ "dueAt": 1200100,
5035
+ "taskId": 3
5036
+ }
5037
+ }
5038
+ ],
5039
+ "nextCursor": "opaque"
5040
+ },
5041
+ "essential": {
5042
+ "logs": [
5043
+ {
5044
+ "sequence": 1,
5045
+ "kind": "wait.started",
5046
+ "operationId": "visit-1",
5047
+ "level": "INFO",
5048
+ "message": "Waiting",
5049
+ "timestamp": "1970-01-01 08:00:00.100 +08:00 (Asia/Shanghai)",
5050
+ "details": {
5051
+ "dueAt": "1970-01-01 08:20:00.100 +08:00 (Asia/Shanghai)",
5052
+ "taskId": 3
5053
+ }
5054
+ }
5055
+ ],
5056
+ "nextCursor": "opaque"
5057
+ }
5058
+ },
5059
+ {
5060
+ "name": "automation-instance-list",
5061
+ "target": "/app/automation/instance/list",
5062
+ "timezone": "Asia/Shanghai",
5063
+ "status": "success",
5064
+ "data": {
5065
+ "instances": [
5066
+ {
5067
+ "threadId": 0,
5068
+ "instanceId": "run",
5069
+ "revision": 3,
5070
+ "phase": "STOPPING",
5071
+ "startedAt": 100
5072
+ }
5073
+ ]
5074
+ },
5075
+ "essential": {
5076
+ "instances": [
5077
+ {
5078
+ "threadId": 0,
5079
+ "instanceId": "run",
5080
+ "revision": 3,
5081
+ "phase": "STOPPING",
5082
+ "startedAt": "1970-01-01 08:00:00.100 +08:00 (Asia/Shanghai)"
5083
+ }
5084
+ ]
5085
+ }
5044
5086
  }
5045
5087
  ]
@@ -420,7 +420,7 @@
420
420
  "value": {
421
421
  "type": "AUTOMATION",
422
422
  "operation": "CREATE",
423
- "title": "",
423
+ "title": "\ufeff",
424
424
  "summary": "Suggest a lower evening brightness",
425
425
  "reasons": [
426
426
  "Observed manual adjustments after the evening routine"
@@ -443,6 +443,310 @@
443
443
  "parseResults": []
444
444
  }
445
445
  }
446
+ },
447
+ {
448
+ "name": "handled success is terminal",
449
+ "type": "AutomationSuggestion",
450
+ "value": {
451
+ "type": "AUTOMATION",
452
+ "operation": "CREATE",
453
+ "title": "Evening lighting",
454
+ "summary": "Suggest a lower evening brightness",
455
+ "reasons": [
456
+ "Observed manual adjustments after the evening routine"
457
+ ],
458
+ "evidence": [
459
+ {
460
+ "sourceType": "BEHAVIOR",
461
+ "sourceId": "fixture-operation-1",
462
+ "occurredAt": 1000,
463
+ "excerpt": "The user selected brightness 30 after brightness 80"
464
+ }
465
+ ],
466
+ "script": {
467
+ "script": "name: Contract fixture\ntask: []\n",
468
+ "scripts": {
469
+ "lighting": "// Fixture source bundle\n",
470
+ "empty": ""
471
+ },
472
+ "sdkVersion": "test-sdk-1",
473
+ "parseResults": []
474
+ },
475
+ "id": "fixture-suggestion-1",
476
+ "spaceId": "fixture-space",
477
+ "runId": "fixture-run",
478
+ "version": 1,
479
+ "status": "RESOLVED",
480
+ "createdAt": 2000,
481
+ "updatedAt": 3000,
482
+ "resolution": {
483
+ "action": "APPLY",
484
+ "operationId": "fixture-apply",
485
+ "handledAt": 3000,
486
+ "actor": {
487
+ "kind": "user",
488
+ "userId": "fixture-user"
489
+ },
490
+ "resourceIds": {
491
+ "automationId": "fixture-automation"
492
+ },
493
+ "result": {
494
+ "status": "success",
495
+ "data": {
496
+ "automationId": "fixture-automation",
497
+ "enabled": true
498
+ }
499
+ }
500
+ }
501
+ }
502
+ },
503
+ {
504
+ "name": "summary shows success outcome",
505
+ "type": "SuggestionSummary",
506
+ "value": {
507
+ "id": "fixture-suggestion-1",
508
+ "type": "AUTOMATION",
509
+ "version": 1,
510
+ "title": "Evening lighting",
511
+ "summary": "Suggest a lower evening brightness",
512
+ "status": "RESOLVED",
513
+ "createdAt": 2000,
514
+ "updatedAt": 3000,
515
+ "outcome": "success"
516
+ }
517
+ },
518
+ {
519
+ "name": "handled partial is terminal",
520
+ "type": "AutomationSuggestion",
521
+ "value": {
522
+ "type": "AUTOMATION",
523
+ "operation": "CREATE",
524
+ "title": "Evening lighting",
525
+ "summary": "Suggest a lower evening brightness",
526
+ "reasons": [
527
+ "Observed manual adjustments after the evening routine"
528
+ ],
529
+ "evidence": [
530
+ {
531
+ "sourceType": "BEHAVIOR",
532
+ "sourceId": "fixture-operation-1",
533
+ "occurredAt": 1000,
534
+ "excerpt": "The user selected brightness 30 after brightness 80"
535
+ }
536
+ ],
537
+ "script": {
538
+ "script": "name: Contract fixture\ntask: []\n",
539
+ "scripts": {
540
+ "lighting": "// Fixture source bundle\n",
541
+ "empty": ""
542
+ },
543
+ "sdkVersion": "test-sdk-1",
544
+ "parseResults": []
545
+ },
546
+ "id": "fixture-suggestion-1",
547
+ "spaceId": "fixture-space",
548
+ "runId": "fixture-run",
549
+ "version": 1,
550
+ "status": "RESOLVED",
551
+ "createdAt": 2000,
552
+ "updatedAt": 3000,
553
+ "resolution": {
554
+ "action": "APPLY",
555
+ "operationId": "fixture-apply",
556
+ "handledAt": 3000,
557
+ "actor": {
558
+ "kind": "user",
559
+ "userId": "fixture-user"
560
+ },
561
+ "resourceIds": {
562
+ "automationId": "fixture-automation"
563
+ },
564
+ "result": {
565
+ "status": "partial",
566
+ "data": {
567
+ "automationId": "fixture-automation",
568
+ "saved": true
569
+ },
570
+ "warnings": [
571
+ {
572
+ "code": "ENABLE_FAILED",
573
+ "message": "Saved, but enabling failed"
574
+ }
575
+ ]
576
+ }
577
+ }
578
+ }
579
+ },
580
+ {
581
+ "name": "summary shows partial outcome",
582
+ "type": "SuggestionSummary",
583
+ "value": {
584
+ "id": "fixture-suggestion-1",
585
+ "type": "AUTOMATION",
586
+ "version": 1,
587
+ "title": "Evening lighting",
588
+ "summary": "Suggest a lower evening brightness",
589
+ "status": "RESOLVED",
590
+ "createdAt": 2000,
591
+ "updatedAt": 3000,
592
+ "outcome": "partial"
593
+ }
594
+ },
595
+ {
596
+ "name": "handled error is terminal",
597
+ "type": "AutomationSuggestion",
598
+ "value": {
599
+ "type": "AUTOMATION",
600
+ "operation": "CREATE",
601
+ "title": "Evening lighting",
602
+ "summary": "Suggest a lower evening brightness",
603
+ "reasons": [
604
+ "Observed manual adjustments after the evening routine"
605
+ ],
606
+ "evidence": [
607
+ {
608
+ "sourceType": "BEHAVIOR",
609
+ "sourceId": "fixture-operation-1",
610
+ "occurredAt": 1000,
611
+ "excerpt": "The user selected brightness 30 after brightness 80"
612
+ }
613
+ ],
614
+ "script": {
615
+ "script": "name: Contract fixture\ntask: []\n",
616
+ "scripts": {
617
+ "lighting": "// Fixture source bundle\n",
618
+ "empty": ""
619
+ },
620
+ "sdkVersion": "test-sdk-1",
621
+ "parseResults": []
622
+ },
623
+ "id": "fixture-suggestion-1",
624
+ "spaceId": "fixture-space",
625
+ "runId": "fixture-run",
626
+ "version": 1,
627
+ "status": "RESOLVED",
628
+ "createdAt": 2000,
629
+ "updatedAt": 3000,
630
+ "resolution": {
631
+ "action": "APPLY",
632
+ "operationId": "fixture-apply",
633
+ "handledAt": 3000,
634
+ "actor": {
635
+ "kind": "user",
636
+ "userId": "fixture-user"
637
+ },
638
+ "resourceIds": {
639
+ "automationId": "fixture-automation"
640
+ },
641
+ "result": {
642
+ "status": "error",
643
+ "error": {
644
+ "code": "INVALID_SCRIPT",
645
+ "message": "Script validation failed"
646
+ }
647
+ }
648
+ }
649
+ }
650
+ },
651
+ {
652
+ "name": "summary shows error outcome",
653
+ "type": "SuggestionSummary",
654
+ "value": {
655
+ "id": "fixture-suggestion-1",
656
+ "type": "AUTOMATION",
657
+ "version": 1,
658
+ "title": "Evening lighting",
659
+ "summary": "Suggest a lower evening brightness",
660
+ "status": "RESOLVED",
661
+ "createdAt": 2000,
662
+ "updatedAt": 3000,
663
+ "outcome": "error"
664
+ }
665
+ },
666
+ {
667
+ "name": "handled unknown is terminal",
668
+ "type": "AutomationSuggestion",
669
+ "value": {
670
+ "type": "AUTOMATION",
671
+ "operation": "CREATE",
672
+ "title": "Evening lighting",
673
+ "summary": "Suggest a lower evening brightness",
674
+ "reasons": [
675
+ "Observed manual adjustments after the evening routine"
676
+ ],
677
+ "evidence": [
678
+ {
679
+ "sourceType": "BEHAVIOR",
680
+ "sourceId": "fixture-operation-1",
681
+ "occurredAt": 1000,
682
+ "excerpt": "The user selected brightness 30 after brightness 80"
683
+ }
684
+ ],
685
+ "script": {
686
+ "script": "name: Contract fixture\ntask: []\n",
687
+ "scripts": {
688
+ "lighting": "// Fixture source bundle\n",
689
+ "empty": ""
690
+ },
691
+ "sdkVersion": "test-sdk-1",
692
+ "parseResults": []
693
+ },
694
+ "id": "fixture-suggestion-1",
695
+ "spaceId": "fixture-space",
696
+ "runId": "fixture-run",
697
+ "version": 1,
698
+ "status": "RESOLVED",
699
+ "createdAt": 2000,
700
+ "updatedAt": 3000,
701
+ "resolution": {
702
+ "action": "APPLY",
703
+ "operationId": "fixture-apply",
704
+ "handledAt": 3000,
705
+ "actor": {
706
+ "kind": "user",
707
+ "userId": "fixture-user"
708
+ },
709
+ "resourceIds": {
710
+ "automationId": "fixture-automation"
711
+ },
712
+ "result": {
713
+ "status": "error",
714
+ "error": {
715
+ "code": "OUTCOME_UNKNOWN",
716
+ "message": "The write outcome is unknown"
717
+ }
718
+ }
719
+ }
720
+ }
721
+ },
722
+ {
723
+ "name": "summary shows unknown outcome",
724
+ "type": "SuggestionSummary",
725
+ "value": {
726
+ "id": "fixture-suggestion-1",
727
+ "type": "AUTOMATION",
728
+ "version": 1,
729
+ "title": "Evening lighting",
730
+ "summary": "Suggest a lower evening brightness",
731
+ "status": "RESOLVED",
732
+ "createdAt": 2000,
733
+ "updatedAt": 3000,
734
+ "outcome": "error"
735
+ }
736
+ },
737
+ {
738
+ "name": "explicit periodic settings True",
739
+ "type": "SuggestionSettings",
740
+ "value": {
741
+ "enabled": true
742
+ }
743
+ },
744
+ {
745
+ "name": "explicit periodic settings False",
746
+ "type": "SuggestionSettings",
747
+ "value": {
748
+ "enabled": false
749
+ }
446
750
  }
447
751
  ],
448
752
  "invalid": [
@@ -918,7 +1222,57 @@
918
1222
  "value": {
919
1223
  "type": "AUTOMATION",
920
1224
  "operation": "CREATE",
921
- "title": "…",
1225
+ "title": "\u0085",
1226
+ "summary": "Suggest a lower evening brightness",
1227
+ "reasons": [
1228
+ "Observed manual adjustments after the evening routine"
1229
+ ],
1230
+ "evidence": [
1231
+ {
1232
+ "sourceType": "BEHAVIOR",
1233
+ "sourceId": "fixture-operation-1",
1234
+ "occurredAt": 1000,
1235
+ "excerpt": "The user selected brightness 30 after brightness 80"
1236
+ }
1237
+ ],
1238
+ "script": {
1239
+ "script": "name: Contract fixture\ntask: []\n",
1240
+ "scripts": {
1241
+ "lighting": "// Fixture source bundle\n",
1242
+ "empty": ""
1243
+ },
1244
+ "sdkVersion": "test-sdk-1",
1245
+ "parseResults": []
1246
+ }
1247
+ }
1248
+ },
1249
+ {
1250
+ "name": "missing enabled",
1251
+ "type": "SuggestionSettings",
1252
+ "value": {}
1253
+ },
1254
+ {
1255
+ "name": "not boolean",
1256
+ "type": "SuggestionSettings",
1257
+ "value": {
1258
+ "enabled": "true"
1259
+ }
1260
+ },
1261
+ {
1262
+ "name": "caller-selected Space",
1263
+ "type": "SuggestionSettings",
1264
+ "value": {
1265
+ "enabled": true,
1266
+ "spaceId": "other"
1267
+ }
1268
+ },
1269
+ {
1270
+ "name": "partial missing data",
1271
+ "type": "AutomationSuggestion",
1272
+ "value": {
1273
+ "type": "AUTOMATION",
1274
+ "operation": "CREATE",
1275
+ "title": "Evening lighting",
922
1276
  "summary": "Suggest a lower evening brightness",
923
1277
  "reasons": [
924
1278
  "Observed manual adjustments after the evening routine"
@@ -939,8 +1293,150 @@
939
1293
  },
940
1294
  "sdkVersion": "test-sdk-1",
941
1295
  "parseResults": []
1296
+ },
1297
+ "id": "fixture-suggestion-1",
1298
+ "spaceId": "fixture-space",
1299
+ "runId": "fixture-run",
1300
+ "version": 1,
1301
+ "status": "RESOLVED",
1302
+ "createdAt": 2000,
1303
+ "updatedAt": 3000,
1304
+ "resolution": {
1305
+ "action": "SAVE",
1306
+ "operationId": "fixture-apply",
1307
+ "handledAt": 3000,
1308
+ "actor": {
1309
+ "kind": "user",
1310
+ "userId": "fixture-user"
1311
+ },
1312
+ "resourceIds": {
1313
+ "automationId": "fixture-automation"
1314
+ },
1315
+ "result": {
1316
+ "status": "partial"
1317
+ }
942
1318
  }
943
1319
  }
1320
+ },
1321
+ {
1322
+ "name": "unknown not a canonical status",
1323
+ "type": "AutomationSuggestion",
1324
+ "value": {
1325
+ "type": "AUTOMATION",
1326
+ "operation": "CREATE",
1327
+ "title": "Evening lighting",
1328
+ "summary": "Suggest a lower evening brightness",
1329
+ "reasons": [
1330
+ "Observed manual adjustments after the evening routine"
1331
+ ],
1332
+ "evidence": [
1333
+ {
1334
+ "sourceType": "BEHAVIOR",
1335
+ "sourceId": "fixture-operation-1",
1336
+ "occurredAt": 1000,
1337
+ "excerpt": "The user selected brightness 30 after brightness 80"
1338
+ }
1339
+ ],
1340
+ "script": {
1341
+ "script": "name: Contract fixture\ntask: []\n",
1342
+ "scripts": {
1343
+ "lighting": "// Fixture source bundle\n",
1344
+ "empty": ""
1345
+ },
1346
+ "sdkVersion": "test-sdk-1",
1347
+ "parseResults": []
1348
+ },
1349
+ "id": "fixture-suggestion-1",
1350
+ "spaceId": "fixture-space",
1351
+ "runId": "fixture-run",
1352
+ "version": 1,
1353
+ "status": "RESOLVED",
1354
+ "createdAt": 2000,
1355
+ "updatedAt": 3000,
1356
+ "resolution": {
1357
+ "action": "SAVE",
1358
+ "operationId": "fixture-apply",
1359
+ "handledAt": 3000,
1360
+ "actor": {
1361
+ "kind": "user",
1362
+ "userId": "fixture-user"
1363
+ },
1364
+ "resourceIds": {
1365
+ "automationId": "fixture-automation"
1366
+ },
1367
+ "result": {
1368
+ "status": "unknown"
1369
+ }
1370
+ }
1371
+ }
1372
+ },
1373
+ {
1374
+ "name": "result extra fields",
1375
+ "type": "AutomationSuggestion",
1376
+ "value": {
1377
+ "type": "AUTOMATION",
1378
+ "operation": "CREATE",
1379
+ "title": "Evening lighting",
1380
+ "summary": "Suggest a lower evening brightness",
1381
+ "reasons": [
1382
+ "Observed manual adjustments after the evening routine"
1383
+ ],
1384
+ "evidence": [
1385
+ {
1386
+ "sourceType": "BEHAVIOR",
1387
+ "sourceId": "fixture-operation-1",
1388
+ "occurredAt": 1000,
1389
+ "excerpt": "The user selected brightness 30 after brightness 80"
1390
+ }
1391
+ ],
1392
+ "script": {
1393
+ "script": "name: Contract fixture\ntask: []\n",
1394
+ "scripts": {
1395
+ "lighting": "// Fixture source bundle\n",
1396
+ "empty": ""
1397
+ },
1398
+ "sdkVersion": "test-sdk-1",
1399
+ "parseResults": []
1400
+ },
1401
+ "id": "fixture-suggestion-1",
1402
+ "spaceId": "fixture-space",
1403
+ "runId": "fixture-run",
1404
+ "version": 1,
1405
+ "status": "RESOLVED",
1406
+ "createdAt": 2000,
1407
+ "updatedAt": 3000,
1408
+ "resolution": {
1409
+ "action": "SAVE",
1410
+ "operationId": "fixture-apply",
1411
+ "handledAt": 3000,
1412
+ "actor": {
1413
+ "kind": "user",
1414
+ "userId": "fixture-user"
1415
+ },
1416
+ "resourceIds": {
1417
+ "automationId": "fixture-automation"
1418
+ },
1419
+ "result": {
1420
+ "status": "success",
1421
+ "retry": true
1422
+ }
1423
+ }
1424
+ }
1425
+ },
1426
+ {
1427
+ "name": "summary rejects invented outcome",
1428
+ "type": "SuggestionSummary",
1429
+ "value": {
1430
+ "id": "fixture-suggestion-1",
1431
+ "type": "AUTOMATION",
1432
+ "version": 1,
1433
+ "title": "Evening lighting",
1434
+ "summary": "Suggest a lower evening brightness",
1435
+ "status": "RESOLVED",
1436
+ "createdAt": 2000,
1437
+ "updatedAt": 3000,
1438
+ "outcome": "unknown"
1439
+ }
944
1440
  }
945
1441
  ]
946
1442
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "manifest": "mhome.app-facade.v1",
3
- "contractVersion": "1.154.0",
3
+ "contractVersion": "1.156.0",
4
4
  "callSchema": "schema/facade-call.v1.schema.json",
5
5
  "routing": "manifest/routing.v1.json",
6
6
  "routingSchema": "schema/routing.v1.schema.json",
@@ -395,6 +395,10 @@
395
395
  "requestTargets": [
396
396
  "/app/automation/start",
397
397
  "/app/automation/stop",
398
+ "/app/automation/instance/stop",
399
+ "/app/automation/instance/list",
400
+ "/app/automation/diagnostic/get",
401
+ "/app/automation/diagnostic/read",
398
402
  "/app/automation/rename",
399
403
  "/app/automation/description/update"
400
404
  ]
@@ -1,5 +1,5 @@
1
1
  {
2
- "contractVersion": "1.154.0",
2
+ "contractVersion": "1.156.0",
3
3
  "operations": {
4
4
  "/app/agent/context/get": "spaceRead",
5
5
  "/app/agent/conversation/get": "spaceRead",
@@ -39,6 +39,9 @@
39
39
  "/app/automation/description/update": "spaceWrite",
40
40
  "/app/automation/detail/get": "spaceRead",
41
41
  "/app/automation/diagnostic/get": "spaceRead",
42
+ "/app/automation/diagnostic/read": "spaceRead",
43
+ "/app/automation/instance/stop": "spaceWrite",
44
+ "/app/automation/instance/list": "spaceRead",
42
45
  "/app/automation/list": "spaceRead",
43
46
  "/app/automation/rename": "spaceWrite",
44
47
  "/app/automation/save": "spaceWrite",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "manifest": "mhome.host-provision.targets.v1",
3
- "contractVersion": "1.154.0",
3
+ "contractVersion": "1.156.0",
4
4
  "contract": "contract/host-provisioning-v1.md",
5
5
  "localTargets": [
6
6
  "/local/host/provision/start",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "manifest": "mhome.hub.targets.v1",
3
- "contractVersion": "1.154.0",
3
+ "contractVersion": "1.156.0",
4
4
  "appTargets": [
5
5
  "/app/hub/get",
6
6
  "/app/hub/remove"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "manifest": "mhome.pod.targets.v1",
3
- "contractVersion": "1.154.0",
3
+ "contractVersion": "1.156.0",
4
4
  "contract": "contract/pod-commissioning-v1.md",
5
5
  "localTargets": [
6
6
  "/local/pod/discovery/start",
@@ -46,12 +46,13 @@
46
46
  "schedules.*.timestamp"
47
47
  ]
48
48
  },
49
+ "/app/automation/instance/list": { "ms": ["instances.*.startedAt"] },
50
+ "/app/automation/diagnostic/read": { "ms": ["logs.*.timestamp", "logs.*.details.dueAt"] },
49
51
  "/app/automation/diagnostic/get": {
50
52
  "ms": [
51
53
  "diagnostics.*.timestamp",
52
54
  "diagnostics.*.startedAt",
53
- "diagnostics.*.finishedAt",
54
- "diagnostics.*.logs.*.timestamp"
55
+ "diagnostics.*.finishedAt"
55
56
  ]
56
57
  },
57
58
  "/app/group/list": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "manifest": "mhome.app-facade.routing.v1",
3
- "contractVersion": "1.154.0",
3
+ "contractVersion": "1.156.0",
4
4
  "targetPrefix": "/app/",
5
5
  "default": {
6
6
  "execution": "spaceMode"
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "manifest": "mhome.messaging.targets.v1",
3
- "contractVersion": "1.154.0",
3
+ "contractVersion": "1.156.0",
4
4
  "requestTargets": [
5
5
  "/app/messaging/provider/list",
6
6
  "/app/messaging/provider-account/list",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mhome/app-facade-protocol",
3
- "version": "1.154.0",
3
+ "version": "1.156.0",
4
4
  "description": "Build-time protocol artifacts for mhome.app-facade",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
package/protocol.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "protocol": "mhome.app-facade",
3
- "contractVersion": "1.154.0",
3
+ "contractVersion": "1.156.0",
4
4
  "manifest": "manifest/app-facade.v1.json",
5
5
  "schemas": {
6
6
  "dashboardCardAuthoring": "schema/dashboard-card-authoring.v1.schema.json",
@@ -137,6 +137,98 @@
137
137
  }
138
138
  }
139
139
  ]
140
+ },
141
+ "instanceInput": {
142
+ "type": "object",
143
+ "additionalProperties": false,
144
+ "properties": {
145
+ "automationId": {
146
+ "type": "string",
147
+ "pattern": "\\S"
148
+ },
149
+ "threadId": {
150
+ "type": "integer",
151
+ "minimum": 0
152
+ },
153
+ "instanceId": {
154
+ "type": "string",
155
+ "pattern": "\\S"
156
+ }
157
+ },
158
+ "required": [
159
+ "automationId",
160
+ "threadId",
161
+ "instanceId"
162
+ ]
163
+ },
164
+ "diagnosticReadInput": {
165
+ "type": "object",
166
+ "additionalProperties": false,
167
+ "properties": {
168
+ "automationId": {
169
+ "type": "string",
170
+ "pattern": "\\S"
171
+ },
172
+ "threadId": {
173
+ "type": "integer",
174
+ "minimum": 0
175
+ },
176
+ "instanceId": {
177
+ "type": "string",
178
+ "pattern": "\\S"
179
+ },
180
+ "cursor": {
181
+ "type": [
182
+ "string",
183
+ "null"
184
+ ]
185
+ }
186
+ },
187
+ "required": [
188
+ "automationId",
189
+ "threadId",
190
+ "instanceId"
191
+ ]
192
+ },
193
+ "instanceStopOutput": {
194
+ "type": "object",
195
+ "additionalProperties": false,
196
+ "properties": {
197
+ "automationId": {
198
+ "type": "string",
199
+ "pattern": "\\S"
200
+ },
201
+ "threadId": {
202
+ "type": "integer",
203
+ "minimum": 0
204
+ },
205
+ "instanceId": {
206
+ "type": "string",
207
+ "pattern": "\\S"
208
+ },
209
+ "state": {
210
+ "enum": [
211
+ "STOPPING",
212
+ "FINISHED"
213
+ ]
214
+ },
215
+ "outcome": {
216
+ "enum": [
217
+ null,
218
+ "SUCCEEDED",
219
+ "FAILED",
220
+ "CANCELLED",
221
+ "INTERRUPTED"
222
+ ]
223
+ }
224
+ },
225
+ "required": [
226
+ "automationId",
227
+ "threadId",
228
+ "instanceId",
229
+ "state",
230
+ "outcome"
231
+ ]
140
232
  }
141
233
  }
142
234
  }
@@ -163,6 +163,16 @@
163
163
  "type": "null"
164
164
  }
165
165
  ]
166
+ },
167
+ "result": {
168
+ "anyOf": [
169
+ {
170
+ "$ref": "#/$defs/ActionResult"
171
+ },
172
+ {
173
+ "type": "null"
174
+ }
175
+ ]
166
176
  }
167
177
  },
168
178
  "required": [
@@ -891,6 +901,21 @@
891
901
  "type": "null"
892
902
  }
893
903
  ]
904
+ },
905
+ "outcome": {
906
+ "anyOf": [
907
+ {
908
+ "enum": [
909
+ "success",
910
+ "partial",
911
+ "error",
912
+ "cancelled"
913
+ ]
914
+ },
915
+ {
916
+ "type": "null"
917
+ }
918
+ ]
894
919
  }
895
920
  },
896
921
  "required": [
@@ -1208,6 +1233,119 @@
1208
1233
  "required": [
1209
1234
  "run"
1210
1235
  ]
1236
+ },
1237
+ "ActionResult": {
1238
+ "title": "App Facade final response",
1239
+ "oneOf": [
1240
+ {
1241
+ "type": "object",
1242
+ "additionalProperties": false,
1243
+ "required": [
1244
+ "status"
1245
+ ],
1246
+ "properties": {
1247
+ "status": {
1248
+ "const": "success"
1249
+ },
1250
+ "data": true,
1251
+ "warnings": {
1252
+ "type": "array",
1253
+ "items": {
1254
+ "$ref": "#/$defs/ActionResult/$defs/problem"
1255
+ }
1256
+ }
1257
+ }
1258
+ },
1259
+ {
1260
+ "type": "object",
1261
+ "additionalProperties": false,
1262
+ "required": [
1263
+ "status",
1264
+ "data"
1265
+ ],
1266
+ "properties": {
1267
+ "status": {
1268
+ "const": "partial"
1269
+ },
1270
+ "data": true,
1271
+ "warnings": {
1272
+ "type": "array",
1273
+ "items": {
1274
+ "$ref": "#/$defs/ActionResult/$defs/problem"
1275
+ }
1276
+ }
1277
+ }
1278
+ },
1279
+ {
1280
+ "type": "object",
1281
+ "additionalProperties": false,
1282
+ "required": [
1283
+ "status",
1284
+ "error"
1285
+ ],
1286
+ "properties": {
1287
+ "status": {
1288
+ "const": "error"
1289
+ },
1290
+ "error": {
1291
+ "$ref": "#/$defs/ActionResult/$defs/problem"
1292
+ },
1293
+ "data": {
1294
+ "type": "string"
1295
+ }
1296
+ }
1297
+ },
1298
+ {
1299
+ "type": "object",
1300
+ "additionalProperties": false,
1301
+ "required": [
1302
+ "status"
1303
+ ],
1304
+ "properties": {
1305
+ "status": {
1306
+ "const": "cancelled"
1307
+ },
1308
+ "warnings": {
1309
+ "type": "array",
1310
+ "items": {
1311
+ "$ref": "#/$defs/ActionResult/$defs/problem"
1312
+ }
1313
+ }
1314
+ }
1315
+ }
1316
+ ],
1317
+ "$defs": {
1318
+ "problem": {
1319
+ "type": "object",
1320
+ "additionalProperties": false,
1321
+ "required": [
1322
+ "code",
1323
+ "message"
1324
+ ],
1325
+ "properties": {
1326
+ "code": {
1327
+ "type": "string"
1328
+ },
1329
+ "message": {
1330
+ "type": "string"
1331
+ },
1332
+ "details": true
1333
+ }
1334
+ }
1335
+ }
1336
+ },
1337
+ "SuggestionSettings": {
1338
+ "type": "object",
1339
+ "properties": {
1340
+ "enabled": {
1341
+ "type": "boolean",
1342
+ "default": true
1343
+ }
1344
+ },
1345
+ "required": [
1346
+ "enabled"
1347
+ ],
1348
+ "additionalProperties": false
1211
1349
  }
1212
1350
  }
1213
1351
  }