dsh-ptc-plus 0.5.2 → 0.5.4
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.
- package/README.en.md +4 -2
- package/README.md +4 -2
- package/client.cjs +3392 -2811
- package/compiler-core.cjs +127 -127
- package/compiler-core.cjs.map +2 -2
- package/docs/README.md +1 -0
- package/docs/adr/0017-track-the-latest-dsh-public-surface.md +4 -2
- package/docs/adr/0019-plugin-settings-and-kill-switch.md +2 -2
- package/docs/adr/0023-global-user-bindings.md +12 -0
- package/docs/adr/0028-attach-to-the-host-ptc-execution-seam.md +1 -1
- package/docs/adr/0030-serve-both-typert-codec-generations-from-one-codec.md +2 -2
- package/docs/adr/0044-coexist-with-the-official-persistent-repl.md +4 -4
- package/docs/adr/0046-gate-the-commit-with-the-semantic-evidence-tier.md +1 -1
- package/docs/adr/0048-supersede-a-rewritten-cell.md +48 -0
- package/docs/adr/0049-prove-a-settlement-against-its-published-record.md +53 -0
- package/docs/adr/0050-read-host-surfaces-through-their-published-contract.md +48 -0
- package/docs/adr/README.md +7 -1
- package/docs/architecture.md +1 -1
- package/docs/capability-planning-components.md +6 -6
- package/docs/capability-projection.md +1 -1
- package/docs/capability-surface.md +133 -0
- package/docs/client-ui.md +17 -15
- package/docs/client-visual-contract.md +7 -7
- package/docs/durability-design.md +9 -2
- package/docs/installation.md +17 -10
- package/docs/panel-concept.md +171 -0
- package/docs/releases/v0.5.2.md +26 -14
- package/docs/releases/v0.5.3.md +77 -0
- package/docs/releases/v0.5.4.md +75 -0
- package/docs/runtime-reference.md +21 -1
- package/docs/user-bindings.en.md +15 -0
- package/docs/user-bindings.md +15 -0
- package/docs/v0.5.3-goals.md +117 -0
- package/docs/verification.md +4 -4
- package/index.js +176 -41
- package/internal/binding-adoption.js +228 -0
- package/internal/capability-command-receipt.js +106 -8
- package/internal/capability-environment.js +1109 -312
- package/internal/capability-plan.js +18 -2
- package/internal/capability-policy.js +13 -0
- package/internal/capability-selection.js +330 -0
- package/internal/config-spec.js +14 -5
- package/internal/cordis-tools-owner.js +2 -1
- package/internal/direct-surface-owner.js +44 -17
- package/internal/edit-transport-owner.js +6 -5
- package/internal/execution-provider-owner.js +6 -0
- package/internal/execution-seam-compat.js +25 -0
- package/internal/host-tool-sdk.js +308 -0
- package/internal/message-sources.js +21 -0
- package/internal/official-repl-priority.js +31 -10
- package/internal/program-bindings.js +25 -5
- package/internal/repl-memory-projection.js +21 -2
- package/internal/runtime-bridge-owner.js +118 -9
- package/internal/runtime-config.js +10 -0
- package/internal/runtime-messages.js +5 -0
- package/internal/session-journal-recovery.js +210 -32
- package/internal/session-journal-schema.js +3 -0
- package/internal/session-journal.js +46 -9
- package/internal/session-log-view.js +69 -7
- package/internal/session-runtime.js +106 -39
- package/internal/settings-compat.js +6 -0
- package/internal/user-bindings-owner.js +126 -6
- package/package.json +59 -37
- package/src/client-authoring-view.js +7 -8
- package/src/client-capabilities-view.js +874 -909
- package/src/client-capability-sort.js +22 -9
- package/src/client-copy.js +118 -272
- package/src/client-indicator-view.js +2 -1
- package/src/client-repl-view.js +35 -16
- package/src/client-settings-view.js +90 -33
- package/src/client-styles.js +67 -19
- package/src/client.js +49 -22
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
/**
|
|
1
|
+
/**
|
|
2
|
+
* Structured command outcome for locale-owned Client receipts; text remains a CLI fallback.
|
|
3
|
+
*
|
|
4
|
+
* A receipt states the one write a command performed: which entry, which choice,
|
|
5
|
+
* and which owner now records it. Whether a cell later reached that entry is a
|
|
6
|
+
* different question with a different owner — a catalogue row's `evidence` field,
|
|
7
|
+
* where a marker means an accepted execution obtained it, and which the page does
|
|
8
|
+
* not state — so a receipt that restated
|
|
9
|
+
* a degree of proof would answer a question this command never asked and could
|
|
10
|
+
* not answer.
|
|
11
|
+
*/
|
|
2
12
|
const PREFIX = '\n\nPTC Plus capability refresh receipt:\n'
|
|
3
13
|
const FALLBACKS = Object.freeze({
|
|
4
14
|
'saved-only': 'Global choice saved, but the session update failed; inspect and retry session',
|
|
@@ -10,22 +20,110 @@ const FALLBACKS = Object.freeze({
|
|
|
10
20
|
off: 'Capability management is off; the session stays with the Host capabilities for session',
|
|
11
21
|
})
|
|
12
22
|
const STATES = new Set(['recorded', 'pending', 'unavailable', 'usage', 'saved-only', 'paused', 'off'])
|
|
23
|
+
const SCOPES = new Set(['session', 'global'])
|
|
24
|
+
const DIMENSIONS = new Set(['availability', 'disclosure'])
|
|
25
|
+
// Every choice `/capabilities set` accepts, so a receipt cannot name a write the
|
|
26
|
+
// command would have refused.
|
|
27
|
+
const SELECTIONS = new Set(['full', 'on-demand', 'closed', 'automatic', 'inherit', 'enabled', 'host', 'adaptive'])
|
|
28
|
+
/**
|
|
29
|
+
* What the receipt's one-line sentence needs from an id: no whitespace, bounded length.
|
|
30
|
+
*
|
|
31
|
+
* Which ids a choice may name is the record vocabulary's question
|
|
32
|
+
* (`capability-selection.js`), answered once where the record is written. Asking it
|
|
33
|
+
* again here would be a second owner of the same vocabulary, and a stricter second
|
|
34
|
+
* owner refuses a record the session already holds: the write lands, the receipt cannot
|
|
35
|
+
* be composed, and the command reports a failure it did not have. This predicate is a
|
|
36
|
+
* strict superset of that vocabulary, so every record a writer accepts is reportable.
|
|
37
|
+
*/
|
|
38
|
+
const ENTRY_ID = /^\S{1,256}$/
|
|
39
|
+
/**
|
|
40
|
+
* Releases up to 0.5.4 appended a saved/delivered/usable report to the same
|
|
41
|
+
* receipt. Such a receipt stays readable — the Client renders the outcome it
|
|
42
|
+
* recorded instead of falling back to its raw text — and the report is dropped
|
|
43
|
+
* before any consumer sees it. Its wording is frozen history this build does not
|
|
44
|
+
* reproduce, so its opening segment plus the stored facts are the whole check.
|
|
45
|
+
*/
|
|
46
|
+
const LEGACY_REPORT = ' Saved: '
|
|
13
47
|
|
|
14
|
-
|
|
48
|
+
function isRecord(value) {
|
|
49
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** One written choice, closed over the vocabulary the writer accepts. */
|
|
53
|
+
function commandRecord(value) {
|
|
54
|
+
if (!isRecord(value) || !SCOPES.has(value.scope) || typeof value.id !== 'string' || !ENTRY_ID.test(value.id)
|
|
55
|
+
|| !SELECTIONS.has(value.selection)
|
|
56
|
+
|| value.dimension !== undefined && !DIMENSIONS.has(value.dimension)
|
|
57
|
+
|| Reflect.ownKeys(value).length !== (value.dimension === undefined ? 3 : 4)) {
|
|
58
|
+
throw new TypeError('invalid capability command record')
|
|
59
|
+
}
|
|
60
|
+
return Object.freeze({
|
|
61
|
+
scope: value.scope,
|
|
62
|
+
id: value.id,
|
|
63
|
+
...(value.dimension === undefined ? {} : { dimension: value.dimension }),
|
|
64
|
+
selection: value.selection,
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The sentence a non-Client reader gets; the Client states the same facts in its own words. */
|
|
69
|
+
function recordFallback(record) {
|
|
70
|
+
const dimension = record.dimension === undefined ? '' : ` ${record.dimension}`
|
|
71
|
+
return `Recorded ${record.id}${dimension} = ${record.selection}`
|
|
72
|
+
+ (record.scope === 'global' ? ' in the global configuration.' : ' for this session.')
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function capabilityCommandReceipt(state, sessionId, error, proposal, record) {
|
|
15
76
|
if (!STATES.has(state) || typeof sessionId !== 'string' || !sessionId) throw new TypeError('invalid capability command receipt')
|
|
16
77
|
if (error !== undefined && (state !== 'saved-only' || typeof error !== 'string' || !error)) throw new TypeError('invalid capability command error')
|
|
17
78
|
if (proposal !== undefined && (state !== 'pending' || !proposal || typeof proposal.commandId !== 'string'
|
|
18
79
|
|| typeof proposal.rawInput !== 'string' || !proposal.message)) throw new TypeError('invalid capability proposal receipt')
|
|
19
|
-
|
|
20
|
-
|
|
80
|
+
// Only a receipt that says the write happened names one: a command whose session
|
|
81
|
+
// write failed reports that failure instead of naming a record it never appended.
|
|
82
|
+
if (record !== undefined && state !== 'recorded') throw new TypeError('invalid capability command record state')
|
|
83
|
+
const written = record === undefined ? undefined : commandRecord(record)
|
|
84
|
+
return `${FALLBACKS[state]} ${sessionId}.${error ? ` ${error}` : ''}`
|
|
85
|
+
+ (written === undefined ? '' : ` ${recordFallback(written)}`)
|
|
86
|
+
+ PREFIX
|
|
87
|
+
+ JSON.stringify({
|
|
88
|
+
schema: 'ptc-capability-command/v1', state, sessionId,
|
|
89
|
+
...(error === undefined ? {} : { error }),
|
|
90
|
+
...(proposal === undefined ? {} : { proposal }),
|
|
91
|
+
...(written === undefined ? {} : { record: written }),
|
|
92
|
+
})
|
|
21
93
|
}
|
|
22
94
|
|
|
95
|
+
/**
|
|
96
|
+
* The receipt a command text carries, or `undefined` for any other text.
|
|
97
|
+
*
|
|
98
|
+
* A receipt this build writes is read only when the whole text is exactly what
|
|
99
|
+
* the writer produces from the facts it stores. A 0.5.4 receipt carries the
|
|
100
|
+
* report described above instead, and its visible sentence cannot be reproduced
|
|
101
|
+
* without keeping that wording, so its stored facts decide: the outcome sentence,
|
|
102
|
+
* the field order and the record of what was written must all be the writer's.
|
|
103
|
+
*/
|
|
23
104
|
export function readCapabilityCommandReceipt(text) {
|
|
24
105
|
if (typeof text !== 'string' || !text.includes(PREFIX)) return undefined
|
|
106
|
+
const cut = text.indexOf(PREFIX)
|
|
107
|
+
let stored
|
|
108
|
+
try { stored = JSON.parse(text.slice(cut + PREFIX.length)) } catch { return undefined }
|
|
109
|
+
if (stored?.schema !== 'ptc-capability-command/v1' || !STATES.has(stored.state)) return undefined
|
|
110
|
+
let current
|
|
25
111
|
try {
|
|
26
|
-
|
|
27
|
-
return receipt?.schema === 'ptc-capability-command/v1' && STATES.has(receipt.state)
|
|
28
|
-
&& typeof receipt.sessionId === 'string' && receipt.sessionId
|
|
29
|
-
&& capabilityCommandReceipt(receipt.state, receipt.sessionId, receipt.error, receipt.proposal) === text ? receipt : undefined
|
|
112
|
+
current = capabilityCommandReceipt(stored.state, stored.sessionId, stored.error, stored.proposal, stored.record)
|
|
30
113
|
} catch { return undefined }
|
|
114
|
+
if (stored.proof === undefined) return current === text ? stored : undefined
|
|
115
|
+
const head = current.slice(0, current.indexOf(PREFIX))
|
|
116
|
+
if (!text.startsWith(head)) return undefined
|
|
117
|
+
const sentence = text.slice(head.length, cut)
|
|
118
|
+
// One report segment, one line, directly after the outcome sentence: the shape
|
|
119
|
+
// the 0.5.4 writer produced from these stored facts.
|
|
120
|
+
if (stored.record !== undefined || !sentence.startsWith(LEGACY_REPORT)
|
|
121
|
+
|| sentence.includes('\n') || sentence.split(LEGACY_REPORT).length !== 2) return undefined
|
|
122
|
+
const fields = Object.keys(JSON.parse(current.slice(current.indexOf(PREFIX) + PREFIX.length)))
|
|
123
|
+
if (Object.keys(stored).join() !== [...fields, 'proof'].join()) return undefined
|
|
124
|
+
return {
|
|
125
|
+
schema: stored.schema, state: stored.state, sessionId: stored.sessionId,
|
|
126
|
+
...(stored.error === undefined ? {} : { error: stored.error }),
|
|
127
|
+
...(stored.proposal === undefined ? {} : { proposal: stored.proposal }),
|
|
128
|
+
}
|
|
31
129
|
}
|