@g9tm/aiassistant-contracts 0.0.0-stage → 1.1.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.
package/README.md CHANGED
@@ -1,3 +1,22 @@
1
- # Temporary Holding Version
1
+ # @g9tm/aiassistant-contracts
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Types of the G9 AI assistant's wire contracts, generated from its JSON Schemas. Types only: nothing runs, nothing is
4
+ bundled.
5
+
6
+ - `eventsV1`: a run's event log (`run.started`, `stage`, `tool`, `text.delta`, `message`, `card`, `waiting`, `result`,
7
+ `run.finished` and the rest), the same for streaming, long polling and a synchronous answer.
8
+ - `blocksV1`: display blocks (table, chart, KPI, compare, timeline and the word-only blocks) with their data handles.
9
+ - `protocolV1`: the model's reply protocol (say, call, plan, ask, load, draw, blocks).
10
+ - `manifestV1`: a product's capability manifest (the app, its capabilities, tools with the hash of their input shape,
11
+ skills and custom blocks).
12
+ - `exportV1`: one line of the neutral export, for moving an existing assistant's data into the stores.
13
+
14
+ ```ts
15
+ import type { eventsV1 } from "@g9tm/aiassistant-contracts";
16
+
17
+ function onEvent(e: eventsV1.RunEvent): void {
18
+ if (e.type === "run.finished") console.log("done at", e.at, "after", e.seq, "events");
19
+ }
20
+ ```
21
+
22
+ Part of the G9 AI assistant library. Documentation: see the guides that ship with the library.
@@ -0,0 +1,73 @@
1
+ /**
2
+ * A table handle such as d1.
3
+ *
4
+ * This interface was referenced by `Blocks`'s JSON-Schema
5
+ * via the `definition` "handle".
6
+ */
7
+ export type Handle = string;
8
+ /**
9
+ * This interface was referenced by `Blocks`'s JSON-Schema
10
+ * via the `definition` "tone".
11
+ */
12
+ export type Tone = "info" | "warn" | "ok" | "danger" | "neutral";
13
+ /**
14
+ * This interface was referenced by `Blocks`'s JSON-Schema
15
+ * via the `definition` "chartKind".
16
+ */
17
+ export type ChartKind = "bars" | "line" | "lines" | "stacked" | "donut";
18
+ /**
19
+ * Display blocks. A 'blockDraft' is what a model may write: data-bearing blocks name a server-side table handle and never carry numbers. A 'block' is what the server sends to clients after filling it; every block carries a plain-text fallback.
20
+ */
21
+ export interface Blocks {
22
+ [k: string]: unknown | undefined;
23
+ }
24
+ export interface BlockDraft {
25
+ type: string;
26
+ }
27
+ /**
28
+ * This interface was referenced by `Blocks`'s JSON-Schema
29
+ * via the `definition` "column".
30
+ */
31
+ export interface Column {
32
+ name: string;
33
+ kind: "text" | "number" | "money" | "percent" | "date" | "day" | "id";
34
+ /**
35
+ * Already translated for the person.
36
+ */
37
+ label: string;
38
+ }
39
+ /**
40
+ * This interface was referenced by `Blocks`'s JSON-Schema
41
+ * via the `definition` "block".
42
+ */
43
+ export interface Block {
44
+ type: string;
45
+ v: 1;
46
+ /**
47
+ * Plain text shown by a client that does not know this type.
48
+ */
49
+ fallbackText: string;
50
+ title?: string;
51
+ text?: string;
52
+ tone?: Tone;
53
+ kind?: string;
54
+ columns?: Column[];
55
+ rows?: unknown[][];
56
+ /**
57
+ * More rows exist on the server (export has them all).
58
+ */
59
+ truncated?: boolean;
60
+ x?: string;
61
+ y?: string;
62
+ by?: string;
63
+ items?: unknown[];
64
+ line?: string;
65
+ pageId?: string;
66
+ fileIds?: string[];
67
+ /**
68
+ * Payload of a host-defined x:* block, validated by the schema the host registered.
69
+ */
70
+ data?: {
71
+ [k: string]: unknown | undefined;
72
+ };
73
+ }
@@ -0,0 +1,2 @@
1
+ /* Generated from contracts/*.schema.json by tools/codegen/generate-ts.mjs. Do not edit. */
2
+ export {};
@@ -0,0 +1,186 @@
1
+ /**
2
+ * One entry of a run's event log. Streaming, long polling and the synchronous mode are three views of the same log. 'seq' grows by one per run and is the cursor.
3
+ */
4
+ export type RunEvent = {
5
+ seq: number;
6
+ type: "run.started" | "stage" | "tier" | "progress" | "tool" | "text.delta" | "message" | "card" | "waiting" | "round" | "guard" | "result" | "reconnect" | "run.finished";
7
+ at: string;
8
+ body: {};
9
+ };
10
+ /**
11
+ * This interface was referenced by `undefined`'s JSON-Schema
12
+ * via the `definition` "provenance".
13
+ */
14
+ export type Provenance = "rule" | "learned" | "model" | "fallback" | "cached";
15
+ /**
16
+ * This interface was referenced by `undefined`'s JSON-Schema
17
+ * via the `definition` "textLine".
18
+ */
19
+ export interface TextLine {
20
+ key: string;
21
+ args?: {
22
+ [k: string]: string | undefined;
23
+ };
24
+ }
25
+ /**
26
+ * This interface was referenced by `undefined`'s JSON-Schema
27
+ * via the `definition` "runStarted".
28
+ */
29
+ export interface RunStarted {
30
+ runId: string;
31
+ capabilityId: string;
32
+ conversationId?: string;
33
+ }
34
+ /**
35
+ * This interface was referenced by `undefined`'s JSON-Schema
36
+ * via the `definition` "stage".
37
+ */
38
+ export interface Stage {
39
+ id: "routing" | "reading" | "thinking" | "tooling" | "checking" | "waiting" | "running" | "role";
40
+ state: "on" | "off";
41
+ role?: string;
42
+ }
43
+ /**
44
+ * This interface was referenced by `undefined`'s JSON-Schema
45
+ * via the `definition` "tier".
46
+ */
47
+ export interface Tier {
48
+ tier: "t0" | "t1" | "t2" | "t3" | "offline";
49
+ }
50
+ /**
51
+ * This interface was referenced by `undefined`'s JSON-Schema
52
+ * via the `definition` "tool".
53
+ */
54
+ export interface Tool {
55
+ name: string;
56
+ title?: TextLine;
57
+ state: "start" | "ok" | "fail";
58
+ ms?: number;
59
+ }
60
+ /**
61
+ * This interface was referenced by `undefined`'s JSON-Schema
62
+ * via the `definition` "textDelta".
63
+ */
64
+ export interface TextDelta {
65
+ text: string;
66
+ }
67
+ /**
68
+ * This interface was referenced by `undefined`'s JSON-Schema
69
+ * via the `definition` "messageBody".
70
+ */
71
+ export interface MessageBody {
72
+ message: Message;
73
+ }
74
+ /**
75
+ * This interface was referenced by `undefined`'s JSON-Schema
76
+ * via the `definition` "message".
77
+ */
78
+ export interface Message {
79
+ id: string;
80
+ role: "user" | "assistant" | "system";
81
+ kind: "text" | "error" | "ask" | "plan" | "block" | "progress" | "files" | "learn" | "routine" | "undo";
82
+ text?: string;
83
+ blocks?: Block[];
84
+ next?: string[];
85
+ provenance?: Provenance;
86
+ at: string;
87
+ }
88
+ export interface Block {
89
+ type: string;
90
+ v: 1;
91
+ /**
92
+ * Plain text shown by a client that does not know this type.
93
+ */
94
+ fallbackText: string;
95
+ title?: string;
96
+ text?: string;
97
+ tone?: "info" | "warn" | "ok" | "danger" | "neutral";
98
+ kind?: string;
99
+ columns?: Column[];
100
+ rows?: unknown[][];
101
+ /**
102
+ * More rows exist on the server (export has them all).
103
+ */
104
+ truncated?: boolean;
105
+ x?: string;
106
+ y?: string;
107
+ by?: string;
108
+ items?: unknown[];
109
+ line?: string;
110
+ pageId?: string;
111
+ fileIds?: string[];
112
+ /**
113
+ * Payload of a host-defined x:* block, validated by the schema the host registered.
114
+ */
115
+ data?: {
116
+ [k: string]: unknown | undefined;
117
+ };
118
+ }
119
+ export interface Column {
120
+ name: string;
121
+ kind: "text" | "number" | "money" | "percent" | "date" | "day" | "id";
122
+ /**
123
+ * Already translated for the person.
124
+ */
125
+ label: string;
126
+ }
127
+ /**
128
+ * This interface was referenced by `undefined`'s JSON-Schema
129
+ * via the `definition` "card".
130
+ */
131
+ export interface Card {
132
+ kind: "plan" | "ask" | "learn" | "routine" | "routine_revision" | "undo";
133
+ id: string;
134
+ body: {};
135
+ }
136
+ /**
137
+ * This interface was referenced by `undefined`'s JSON-Schema
138
+ * via the `definition` "waiting".
139
+ */
140
+ export interface Waiting {
141
+ for: "confirm" | "answer";
142
+ id: string;
143
+ expiresAt?: string;
144
+ }
145
+ /**
146
+ * This interface was referenced by `undefined`'s JSON-Schema
147
+ * via the `definition` "round".
148
+ */
149
+ export interface Round {
150
+ index: number;
151
+ modelId: string;
152
+ tokensIn?: number;
153
+ cached?: number;
154
+ out?: number;
155
+ ms?: number;
156
+ }
157
+ /**
158
+ * The structured output of a non-conversation capability (ask, one-shot, pipeline, sweep, enrichment); used is false when no model answered.
159
+ *
160
+ * This interface was referenced by `undefined`'s JSON-Schema
161
+ * via the `definition` "result".
162
+ */
163
+ export interface Result {
164
+ used: boolean;
165
+ provenance: Provenance;
166
+ output?: unknown;
167
+ code?: string;
168
+ }
169
+ /**
170
+ * This interface was referenced by `undefined`'s JSON-Schema
171
+ * via the `definition` "guard".
172
+ */
173
+ export interface Guard {
174
+ name: string;
175
+ pass: boolean;
176
+ code?: string;
177
+ }
178
+ /**
179
+ * This interface was referenced by `undefined`'s JSON-Schema
180
+ * via the `definition` "runFinished".
181
+ */
182
+ export interface RunFinished {
183
+ outcome: "done" | "failed" | "cancelled";
184
+ code?: string;
185
+ provenance?: Provenance;
186
+ }
@@ -0,0 +1,2 @@
1
+ /* Generated from contracts/*.schema.json by tools/codegen/generate-ts.mjs. Do not edit. */
2
+ export {};
@@ -0,0 +1,19 @@
1
+ /**
2
+ * One line of a neutral export (JSON Lines). A host exports its existing assistant data in this shape; the import tool places each record in the right scope. Texts are plain (decrypted by the exporting host); the folder must be kept private and deleted after import.
3
+ */
4
+ export type ExportRecord = {
5
+ record: "conversation" | "message" | "note" | "alias" | "routine" | "finding" | "gate" | "setting" | "usage" | "file";
6
+ scope: {
7
+ app: string;
8
+ space?: string;
9
+ realm?: string;
10
+ user?: string;
11
+ level?: "general" | "app" | "space" | "user";
12
+ };
13
+ /**
14
+ * The exporting host's own id, kept as a reference so related records can be linked.
15
+ */
16
+ id?: string;
17
+ at?: string;
18
+ data?: {};
19
+ };
@@ -0,0 +1,2 @@
1
+ /* Generated from contracts/*.schema.json by tools/codegen/generate-ts.mjs. Do not edit. */
2
+ export {};
@@ -0,0 +1,5 @@
1
+ export type * as blocksV1 from "./blocksV1.js";
2
+ export type * as eventsV1 from "./eventsV1.js";
3
+ export type * as exportV1 from "./exportV1.js";
4
+ export type * as manifestV1 from "./manifestV1.js";
5
+ export type * as protocolV1 from "./protocolV1.js";
package/dist/index.js ADDED
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,43 @@
1
+ /**
2
+ * What a host offers its assistant, written at build time so a change is visible in review and learned items that a change would break can be listed before release.
3
+ */
4
+ export interface AssistantManifest {
5
+ manifest: 1;
6
+ app: {
7
+ id: string;
8
+ realm?: string;
9
+ hasSpaces?: boolean;
10
+ };
11
+ capabilities: {
12
+ id: string;
13
+ kind: "conversation" | "ask" | "pipeline" | "oneShot" | "sweep" | "enrichment";
14
+ fastPath?: boolean;
15
+ guards?: string[];
16
+ permission?: string;
17
+ tier?: string;
18
+ }[];
19
+ tools: {
20
+ name: string;
21
+ group: string;
22
+ risk: "read" | "change" | "dangerous" | "disabled";
23
+ permission?: string;
24
+ switch?: string;
25
+ effects?: ("idempotent" | "undoable" | "dryRunnable" | "outbound" | "money" | "bulk")[];
26
+ outputTrust?: "trusted" | "untrusted";
27
+ core?: boolean;
28
+ hiddenNames?: string[];
29
+ schemaHash: string;
30
+ }[];
31
+ skills: {
32
+ name: string;
33
+ parent?: string;
34
+ group?: string;
35
+ budget: number;
36
+ locked?: boolean;
37
+ kind?: "skill" | "runbook";
38
+ hash: string;
39
+ }[];
40
+ instantRules?: string[];
41
+ routineSeeds?: string[];
42
+ blocks?: string[];
43
+ }
@@ -0,0 +1,2 @@
1
+ /* Generated from contracts/*.schema.json by tools/codegen/generate-ts.mjs. Do not edit. */
2
+ export {};
@@ -0,0 +1,136 @@
1
+ /**
2
+ * What a model writes in the JSON dialect: exactly one object per turn. 'say' alone ends the turn; at most one of call, plan, ask, load and draw asks the server to act. Display fields are allowed only when no action is present.
3
+ */
4
+ export type AssistantReply = {
5
+ [k: string]: unknown | undefined;
6
+ } & ({
7
+ say: {
8
+ [k: string]: unknown | undefined;
9
+ };
10
+ } | {
11
+ [k: string]: unknown | undefined;
12
+ }) & {
13
+ /**
14
+ * Text for the person.
15
+ */
16
+ say?: string;
17
+ call?: Call;
18
+ plan?: Plan;
19
+ ask?: Ask;
20
+ load?: Load;
21
+ draw?: Draw;
22
+ /**
23
+ * @maxItems 8
24
+ */
25
+ blocks?: BlockDraft[];
26
+ /**
27
+ * @maxItems 4
28
+ */
29
+ next?: string[];
30
+ /**
31
+ * Something the person said that is worth keeping; the server decides whether it may become a note.
32
+ */
33
+ learn?: string;
34
+ /**
35
+ * @maxItems 3
36
+ */
37
+ flags?: Flag[];
38
+ /**
39
+ * A page id the host knows by name.
40
+ */
41
+ open?: string;
42
+ };
43
+ /**
44
+ * This interface was referenced by `undefined`'s JSON-Schema
45
+ * via the `definition` "toolName".
46
+ */
47
+ export type ToolName = string;
48
+ /**
49
+ * This interface was referenced by `undefined`'s JSON-Schema
50
+ * via the `definition` "load".
51
+ */
52
+ export type Load = Load1 & {
53
+ /**
54
+ * @maxItems 4
55
+ */
56
+ skills?: string[];
57
+ /**
58
+ * @maxItems 8
59
+ */
60
+ tools?: string[];
61
+ };
62
+ export type Load1 = {
63
+ [k: string]: unknown | undefined;
64
+ };
65
+ export type BlockDraft = {
66
+ type: string;
67
+ };
68
+ /**
69
+ * This interface was referenced by `undefined`'s JSON-Schema
70
+ * via the `definition` "call".
71
+ */
72
+ export interface Call {
73
+ tool: ToolName;
74
+ input?: {};
75
+ }
76
+ /**
77
+ * This interface was referenced by `undefined`'s JSON-Schema
78
+ * via the `definition` "plan".
79
+ */
80
+ export interface Plan {
81
+ title: string;
82
+ more?: boolean;
83
+ /**
84
+ * @minItems 1
85
+ * @maxItems 30
86
+ */
87
+ steps: [PlanStep, ...PlanStep[]];
88
+ }
89
+ /**
90
+ * This interface was referenced by `undefined`'s JSON-Schema
91
+ * via the `definition` "planStep".
92
+ */
93
+ export interface PlanStep {
94
+ tool: ToolName;
95
+ input?: {};
96
+ text?: string;
97
+ }
98
+ /**
99
+ * This interface was referenced by `undefined`'s JSON-Schema
100
+ * via the `definition` "ask".
101
+ */
102
+ export interface Ask {
103
+ question: string;
104
+ /**
105
+ * @maxItems 12
106
+ */
107
+ options?: AskOption[];
108
+ multi?: boolean;
109
+ /**
110
+ * Ask the person for a secret by name; the value never reaches the model.
111
+ */
112
+ secret?: string;
113
+ }
114
+ /**
115
+ * This interface was referenced by `undefined`'s JSON-Schema
116
+ * via the `definition` "askOption".
117
+ */
118
+ export interface AskOption {
119
+ label: string;
120
+ hint?: string;
121
+ }
122
+ /**
123
+ * This interface was referenced by `undefined`'s JSON-Schema
124
+ * via the `definition` "draw".
125
+ */
126
+ export interface Draw {
127
+ prompt: string;
128
+ }
129
+ /**
130
+ * This interface was referenced by `undefined`'s JSON-Schema
131
+ * via the `definition` "flag".
132
+ */
133
+ export interface Flag {
134
+ key: string;
135
+ text: string;
136
+ }
@@ -0,0 +1,2 @@
1
+ /* Generated from contracts/*.schema.json by tools/codegen/generate-ts.mjs. Do not edit. */
2
+ export {};
package/package.json CHANGED
@@ -1,6 +1,31 @@
1
1
  {
2
2
  "name": "@g9tm/aiassistant-contracts",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.1.0",
4
+ "description": "Types of the G9 AI assistant wire contracts, generated from the JSON Schemas.",
5
+ "license": "MIT",
6
+ "author": {
7
+ "name": "Iman Kari",
8
+ "url": "G9TM"
9
+ },
10
+ "type": "module",
11
+ "sideEffects": false,
12
+ "main": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "exports": {
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.js"
18
+ }
19
+ },
20
+ "files": [
21
+ "dist",
22
+ "README.md"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "scripts": {
28
+ "build": "tsc -p tsconfig.json",
29
+ "typecheck": "tsc -p tsconfig.json --noEmit"
30
+ }
6
31
  }