@anchrd/intel-contract 0.17.0 → 0.19.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/dist/contract/flow-run.d.ts +2 -2
- package/dist/contract/flow.d.ts +33 -11
- package/dist/contract/flow.js +66 -5
- package/package.json +1 -1
|
@@ -130,9 +130,9 @@ export declare const FlowRunStep: z.ZodObject<{
|
|
|
130
130
|
}, z.core.$strict>, z.ZodObject<{
|
|
131
131
|
kind: z.ZodLiteral<"tool">;
|
|
132
132
|
configuration: z.ZodObject<{
|
|
133
|
-
|
|
133
|
+
server: z.ZodString;
|
|
134
|
+
allow: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
134
135
|
fingerprint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
135
|
-
arguments: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
136
136
|
}, z.core.$strict>;
|
|
137
137
|
id: z.ZodString;
|
|
138
138
|
position: z.ZodObject<{
|
package/dist/contract/flow.d.ts
CHANGED
|
@@ -106,9 +106,9 @@ export declare const FlowNode: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
|
106
106
|
}, z.core.$strict>, z.ZodObject<{
|
|
107
107
|
kind: z.ZodLiteral<"tool">;
|
|
108
108
|
configuration: z.ZodObject<{
|
|
109
|
-
|
|
109
|
+
server: z.ZodString;
|
|
110
|
+
allow: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
110
111
|
fingerprint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
111
|
-
arguments: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
112
112
|
}, z.core.$strict>;
|
|
113
113
|
id: z.ZodString;
|
|
114
114
|
position: z.ZodObject<{
|
|
@@ -245,9 +245,9 @@ export declare const FlowGraph: z.ZodObject<{
|
|
|
245
245
|
}, z.core.$strict>, z.ZodObject<{
|
|
246
246
|
kind: z.ZodLiteral<"tool">;
|
|
247
247
|
configuration: z.ZodObject<{
|
|
248
|
-
|
|
248
|
+
server: z.ZodString;
|
|
249
|
+
allow: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
249
250
|
fingerprint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
250
|
-
arguments: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
251
251
|
}, z.core.$strict>;
|
|
252
252
|
id: z.ZodString;
|
|
253
253
|
position: z.ZodObject<{
|
|
@@ -396,9 +396,9 @@ export declare const FlowVersion: z.ZodObject<{
|
|
|
396
396
|
}, z.core.$strict>, z.ZodObject<{
|
|
397
397
|
kind: z.ZodLiteral<"tool">;
|
|
398
398
|
configuration: z.ZodObject<{
|
|
399
|
-
|
|
399
|
+
server: z.ZodString;
|
|
400
|
+
allow: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
400
401
|
fingerprint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
401
|
-
arguments: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
402
402
|
}, z.core.$strict>;
|
|
403
403
|
id: z.ZodString;
|
|
404
404
|
position: z.ZodObject<{
|
|
@@ -550,9 +550,9 @@ export declare const FlowDocument: z.ZodObject<{
|
|
|
550
550
|
}, z.core.$strict>, z.ZodObject<{
|
|
551
551
|
kind: z.ZodLiteral<"tool">;
|
|
552
552
|
configuration: z.ZodObject<{
|
|
553
|
-
|
|
553
|
+
server: z.ZodString;
|
|
554
|
+
allow: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
554
555
|
fingerprint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
555
|
-
arguments: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
556
556
|
}, z.core.$strict>;
|
|
557
557
|
id: z.ZodString;
|
|
558
558
|
position: z.ZodObject<{
|
|
@@ -673,7 +673,7 @@ export declare const FlowRequirements: z.ZodObject<{
|
|
|
673
673
|
title: z.ZodString;
|
|
674
674
|
}, z.core.$strict>>;
|
|
675
675
|
hiddenNodes: z.ZodNumber;
|
|
676
|
-
|
|
676
|
+
servers: z.ZodArray<z.ZodString>;
|
|
677
677
|
}, z.core.$strict>;
|
|
678
678
|
export type FlowRequirements = z.infer<typeof FlowRequirements>;
|
|
679
679
|
export declare const FlowValidation: z.ZodObject<{
|
|
@@ -801,9 +801,9 @@ export declare const SaveFlowVersionInput: z.ZodObject<{
|
|
|
801
801
|
}, z.core.$strict>, z.ZodObject<{
|
|
802
802
|
kind: z.ZodLiteral<"tool">;
|
|
803
803
|
configuration: z.ZodObject<{
|
|
804
|
-
|
|
804
|
+
server: z.ZodString;
|
|
805
|
+
allow: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString>>>;
|
|
805
806
|
fingerprint: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
806
|
-
arguments: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
807
807
|
}, z.core.$strict>;
|
|
808
808
|
id: z.ZodString;
|
|
809
809
|
position: z.ZodObject<{
|
|
@@ -899,6 +899,21 @@ export declare const FlowPublishCall: z.ZodObject<{
|
|
|
899
899
|
available: z.ZodBoolean;
|
|
900
900
|
}, z.core.$strict>;
|
|
901
901
|
export type FlowPublishCall = z.infer<typeof FlowPublishCall>;
|
|
902
|
+
/**
|
|
903
|
+
* What a tool step will be allowed to reach once this version is published (#517).
|
|
904
|
+
*
|
|
905
|
+
* ⚠️ It is in the preview because publishing FREEZES it: from that moment the step's surface is
|
|
906
|
+
* pinned, and a function the provider adds later is not inherited. An author who cannot see the
|
|
907
|
+
* surface before confirming is asked to freeze something they were never shown.
|
|
908
|
+
*/
|
|
909
|
+
export declare const FlowPublishTool: z.ZodObject<{
|
|
910
|
+
nodeId: z.ZodString;
|
|
911
|
+
nodeLabel: z.ZodString;
|
|
912
|
+
server: z.ZodString;
|
|
913
|
+
allow: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
914
|
+
available: z.ZodBoolean;
|
|
915
|
+
}, z.core.$strict>;
|
|
916
|
+
export type FlowPublishTool = z.infer<typeof FlowPublishTool>;
|
|
902
917
|
export declare const FlowPublishPreview: z.ZodObject<{
|
|
903
918
|
flowId: z.ZodString;
|
|
904
919
|
versionId: z.ZodString;
|
|
@@ -917,6 +932,13 @@ export declare const FlowPublishPreview: z.ZodObject<{
|
|
|
917
932
|
freezes: z.ZodBoolean;
|
|
918
933
|
available: z.ZodBoolean;
|
|
919
934
|
}, z.core.$strict>>;
|
|
935
|
+
tools: z.ZodArray<z.ZodObject<{
|
|
936
|
+
nodeId: z.ZodString;
|
|
937
|
+
nodeLabel: z.ZodString;
|
|
938
|
+
server: z.ZodString;
|
|
939
|
+
allow: z.ZodNullable<z.ZodArray<z.ZodString>>;
|
|
940
|
+
available: z.ZodBoolean;
|
|
941
|
+
}, z.core.$strict>>;
|
|
920
942
|
}, z.core.$strict>;
|
|
921
943
|
export type FlowPublishPreview = z.infer<typeof FlowPublishPreview>;
|
|
922
944
|
export declare const RelationNodeKind: z.ZodEnum<{
|
package/dist/contract/flow.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { IdempotencyKey, IntelId, IsoDateTime, LinkConfiguration } from "./contract.js";
|
|
3
|
-
import { ToolName } from "./tool.js";
|
|
3
|
+
import { serverOf, ToolName, ToolServerHandle } from "./tool.js";
|
|
4
4
|
export const FlowNodeId = z.string().regex(/^[A-Za-z0-9][A-Za-z0-9_-]{0,99}$/);
|
|
5
5
|
export const FlowPosition = z.strictObject({ x: z.number().finite(), y: z.number().finite() });
|
|
6
6
|
// A node has a title and nothing else to write in prose (#39). A second free text beside it was
|
|
@@ -77,17 +77,60 @@ export const FlowNode = z.discriminatedUnion("kind", [
|
|
|
77
77
|
}),
|
|
78
78
|
z.strictObject({ ...FlowNodeBase, kind: z.literal("upload"), configuration: LinkConfiguration }),
|
|
79
79
|
z.strictObject({ ...FlowNodeBase, kind: z.literal("table"), configuration: LinkConfiguration }),
|
|
80
|
+
/**
|
|
81
|
+
* A tool step names a SERVER, and optionally the functions of it that this step may use.
|
|
82
|
+
*
|
|
83
|
+
* ⚠️ It named a single function until #489, together with a raw argument object the author had to
|
|
84
|
+
* write as JSON. That modelled the protocol instead of the intent: an author gives a step access
|
|
85
|
+
* to Notion; WHICH of Notion's 28 functions runs, and with which arguments, follows from the
|
|
86
|
+
* step's instruction and can only be known while the flow runs.
|
|
87
|
+
*
|
|
88
|
+
* `allow: null` means every function of that server. A list narrows it, and every entry has to
|
|
89
|
+
* belong to `server` — checked below, because a name from another server would make the step ask
|
|
90
|
+
* for something the portal routes somewhere else entirely.
|
|
91
|
+
*
|
|
92
|
+
* ⚠️ `allow` is an INSTRUCTION to the agent, not a boundary Intel enforces (#518). Intel is a
|
|
93
|
+
* library: it says what is to be done, it does not execute. A flow is carried out by an agent
|
|
94
|
+
* that reaches the portal with its OWN token, and that agent may call the portal directly —
|
|
95
|
+
* Intel never sees the call. What bounds it is the agent's own portal grant, checked by the
|
|
96
|
+
* portal on every call; what `allow` does is tell the agent which of those functions this step
|
|
97
|
+
* is meant to use, the same way an instruction step tells it what to write.
|
|
98
|
+
*
|
|
99
|
+
* That is not a gap to be closed by adding a check here. Enforcing it would mean routing every
|
|
100
|
+
* call through Intel and making it the executor — the one thing this product is not.
|
|
101
|
+
*
|
|
102
|
+
* ⚠️ There is deliberately no `arguments` field any more. Arguments are produced at run time and
|
|
103
|
+
* validated against the tool's own `inputSchema` from a live `tools/list`; a stored copy would be
|
|
104
|
+
* a second source for something the far side already defines, and it would go stale silently.
|
|
105
|
+
*/
|
|
80
106
|
z.strictObject({
|
|
81
107
|
...FlowNodeBase,
|
|
82
108
|
kind: z.literal("tool"),
|
|
83
|
-
configuration: z
|
|
84
|
-
|
|
109
|
+
configuration: z
|
|
110
|
+
.strictObject({
|
|
111
|
+
server: ToolServerHandle,
|
|
112
|
+
allow: z.array(ToolName).nullable().default(null),
|
|
85
113
|
fingerprint: z
|
|
86
114
|
.string()
|
|
87
115
|
.regex(/^[a-f0-9]{64}$/)
|
|
88
116
|
.nullable()
|
|
89
117
|
.default(null),
|
|
90
|
-
|
|
118
|
+
})
|
|
119
|
+
.check((ctx) => {
|
|
120
|
+
const { server, allow } = ctx.value;
|
|
121
|
+
if (allow === null)
|
|
122
|
+
return;
|
|
123
|
+
// The prefix rule is the contract's own (`serverOf`), so a step cannot claim a function
|
|
124
|
+
// that the portal would route somewhere else entirely.
|
|
125
|
+
for (const name of allow) {
|
|
126
|
+
if (serverOf(name, [server]) === null) {
|
|
127
|
+
ctx.issues.push({
|
|
128
|
+
code: "custom",
|
|
129
|
+
input: name,
|
|
130
|
+
message: `An allowed function has to belong to the step's server: ${name} is not a function of ${server}`,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
91
134
|
}),
|
|
92
135
|
}),
|
|
93
136
|
z.strictObject({
|
|
@@ -222,7 +265,7 @@ export const FlowRequirements = z.strictObject({
|
|
|
222
265
|
versionId: IntelId.nullable(),
|
|
223
266
|
nodes: z.array(ReferencedNode),
|
|
224
267
|
hiddenNodes: z.number().int().nonnegative(),
|
|
225
|
-
|
|
268
|
+
servers: z.array(ToolServerHandle),
|
|
226
269
|
});
|
|
227
270
|
// What stands between this flow and a run, asked on demand and answered for the person asking.
|
|
228
271
|
//
|
|
@@ -372,10 +415,28 @@ export const FlowPublishCall = z.strictObject({
|
|
|
372
415
|
// The callee has a published version to be called at all. `false` is what publishing will refuse.
|
|
373
416
|
available: z.boolean(),
|
|
374
417
|
});
|
|
418
|
+
/**
|
|
419
|
+
* What a tool step will be allowed to reach once this version is published (#517).
|
|
420
|
+
*
|
|
421
|
+
* ⚠️ It is in the preview because publishing FREEZES it: from that moment the step's surface is
|
|
422
|
+
* pinned, and a function the provider adds later is not inherited. An author who cannot see the
|
|
423
|
+
* surface before confirming is asked to freeze something they were never shown.
|
|
424
|
+
*/
|
|
425
|
+
export const FlowPublishTool = z.strictObject({
|
|
426
|
+
nodeId: FlowNodeId,
|
|
427
|
+
nodeLabel: z.string().min(1).max(160),
|
|
428
|
+
server: ToolServerHandle,
|
|
429
|
+
// `null` is "every function of that server". A list is what the step narrowed itself to, and it
|
|
430
|
+
// is spelled out rather than counted: the whole point of the preview is that a human can read it.
|
|
431
|
+
allow: z.array(ToolName).nullable(),
|
|
432
|
+
// The server is reachable for the person publishing. `false` is what publishing will refuse.
|
|
433
|
+
available: z.boolean(),
|
|
434
|
+
});
|
|
375
435
|
export const FlowPublishPreview = z.strictObject({
|
|
376
436
|
flowId: IntelId,
|
|
377
437
|
versionId: IntelId,
|
|
378
438
|
calls: z.array(FlowPublishCall),
|
|
439
|
+
tools: z.array(FlowPublishTool),
|
|
379
440
|
});
|
|
380
441
|
// A flow has no share schema of its own. A grant sits on the folder a flow is filed in and inherits
|
|
381
442
|
// down from there (ADR-0004 §2); a narrower grant beside it would destroy the subtree guarantee
|