@graview/tools 0.1.62 → 0.1.64
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/agent/tools.d.ts +15 -0
- package/dist/agent/tools.d.ts.map +1 -1
- package/dist/agent/tools.js +46 -6
- package/dist/agent/tools.js.map +1 -1
- package/dist/agent/workflow-tools.d.ts +55 -0
- package/dist/agent/workflow-tools.d.ts.map +1 -0
- package/dist/agent/workflow-tools.js +82 -0
- package/dist/agent/workflow-tools.js.map +1 -0
- package/dist/cli.d.ts +2 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +11 -3
- package/dist/cli.js.map +1 -1
- package/dist/edit.d.ts +10 -2
- package/dist/edit.d.ts.map +1 -1
- package/dist/edit.js +4 -1
- package/dist/edit.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/starter.d.ts +17 -3
- package/dist/starter.d.ts.map +1 -1
- package/dist/starter.js +64 -7
- package/dist/starter.js.map +1 -1
- package/dist/tidy/away.d.ts +8 -1
- package/dist/tidy/away.d.ts.map +1 -1
- package/dist/tidy/away.js +3 -1
- package/dist/tidy/away.js.map +1 -1
- package/dist/tidy/dream.d.ts.map +1 -1
- package/dist/tidy/dream.js +7 -0
- package/dist/tidy/dream.js.map +1 -1
- package/dist/tidy/system-one.d.ts +6 -0
- package/dist/tidy/system-one.d.ts.map +1 -1
- package/dist/tidy/system-one.js +10 -1
- package/dist/tidy/system-one.js.map +1 -1
- package/dist/workflow-cli.d.ts +20 -0
- package/dist/workflow-cli.d.ts.map +1 -0
- package/dist/workflow-cli.js +187 -0
- package/dist/workflow-cli.js.map +1 -0
- package/dist/workflows/ask.d.ts +20 -0
- package/dist/workflows/ask.d.ts.map +1 -0
- package/dist/workflows/ask.js +42 -0
- package/dist/workflows/ask.js.map +1 -0
- package/dist/workflows/log.d.ts +4 -0
- package/dist/workflows/log.d.ts.map +1 -0
- package/dist/workflows/log.js +16 -0
- package/dist/workflows/log.js.map +1 -0
- package/dist/workflows/run-act.d.ts +4 -0
- package/dist/workflows/run-act.d.ts.map +1 -0
- package/dist/workflows/run-act.js +147 -0
- package/dist/workflows/run-act.js.map +1 -0
- package/dist/workflows/run-agent.d.ts +4 -0
- package/dist/workflows/run-agent.d.ts.map +1 -0
- package/dist/workflows/run-agent.js +91 -0
- package/dist/workflows/run-agent.js.map +1 -0
- package/dist/workflows/run-archive.d.ts +4 -0
- package/dist/workflows/run-archive.d.ts.map +1 -0
- package/dist/workflows/run-archive.js +121 -0
- package/dist/workflows/run-archive.js.map +1 -0
- package/dist/workflows/run-classify.d.ts +4 -0
- package/dist/workflows/run-classify.d.ts.map +1 -0
- package/dist/workflows/run-classify.js +157 -0
- package/dist/workflows/run-classify.js.map +1 -0
- package/dist/workflows/run-generate.d.ts +4 -0
- package/dist/workflows/run-generate.d.ts.map +1 -0
- package/dist/workflows/run-generate.js +126 -0
- package/dist/workflows/run-generate.js.map +1 -0
- package/dist/workflows/run.d.ts +5 -0
- package/dist/workflows/run.d.ts.map +1 -0
- package/dist/workflows/run.js +247 -0
- package/dist/workflows/run.js.map +1 -0
- package/dist/workflows/seat.d.ts +20 -0
- package/dist/workflows/seat.d.ts.map +1 -0
- package/dist/workflows/seat.js +27 -0
- package/dist/workflows/seat.js.map +1 -0
- package/dist/workflows/steps.d.ts +7 -0
- package/dist/workflows/steps.d.ts.map +1 -0
- package/dist/workflows/steps.js +21 -0
- package/dist/workflows/steps.js.map +1 -0
- package/dist/workflows/types.d.ts +213 -0
- package/dist/workflows/types.d.ts.map +1 -0
- package/dist/workflows/types.js +3 -0
- package/dist/workflows/types.js.map +1 -0
- package/dist/workflows.d.ts +14 -0
- package/dist/workflows.d.ts.map +1 -0
- package/dist/workflows.js +24 -0
- package/dist/workflows.js.map +1 -0
- package/package.json +7 -3
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { pluralOf } from "@graview/core";
|
|
2
|
+
import { keyedId, recordsOver, workflowKey, workflowValue } from "@graview/core/workflows";
|
|
3
|
+
/*
|
|
4
|
+
* RUN AN ACT (Roadmap f-job-step-types, f-job-idempotency): once, or once
|
|
5
|
+
* per record `over` picks as the run's author sees them — the record the
|
|
6
|
+
* act's subject when the step does not say it, and what `{ expr }` values
|
|
7
|
+
* read.
|
|
8
|
+
*
|
|
9
|
+
* A KEY MAKES A RERUN AN UPDATE. A step that says `key` makes each record
|
|
10
|
+
* under an id worked out from the workflow's name and the key
|
|
11
|
+
* (`<prefix>:wf.<workflow>.<key>`), asked for as a client asks for one
|
|
12
|
+
* (f-1-0-client-ids), so the store itself refuses a second record of the
|
|
13
|
+
* same key. A rerun finds the record it made last time by that id — or, for
|
|
14
|
+
* an act that makes its own ids, by the key kept on the lineage of the op
|
|
15
|
+
* that made it — and changes only what differs, through the kind's edit;
|
|
16
|
+
* nothing differing is nothing new. A record a person removed since is not
|
|
17
|
+
* made again: the run holds it back and says so. Without `key`, a call
|
|
18
|
+
* that would change nothing is not made.
|
|
19
|
+
*/
|
|
20
|
+
/** The record an earlier run of this workflow made under a key, by the key on the lineage of the op that made it. */
|
|
21
|
+
function madeUnderKey(store, author, key) {
|
|
22
|
+
for (const op of [...store.log.all()].reverse()) {
|
|
23
|
+
if (op.author.id !== author || op.lineage?.key !== key)
|
|
24
|
+
continue;
|
|
25
|
+
const added = op.primitives.find((primitive) => primitive.op === "add-node");
|
|
26
|
+
if (added && added.op === "add-node")
|
|
27
|
+
return added.node.id;
|
|
28
|
+
}
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
/** Whether the log ever held a record under this id. */
|
|
32
|
+
const everMade = (store, id) => store.log.all().some((op) => op.primitives.some((primitive) => primitive.op === "add-node" && primitive.node.id === id));
|
|
33
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
34
|
+
/** The fields a would-be record sets that a record already standing holds otherwise. */
|
|
35
|
+
function differing(store, made, standing) {
|
|
36
|
+
const definition = store.schema.tryDefinition(standing.kind);
|
|
37
|
+
const fields = Object.keys(definition?.fields?.shape ?? {});
|
|
38
|
+
const out = {};
|
|
39
|
+
for (const field of fields)
|
|
40
|
+
if (field in made && !same(made[field], standing[field]))
|
|
41
|
+
out[field] = made[field];
|
|
42
|
+
return out;
|
|
43
|
+
}
|
|
44
|
+
/** The first record a call would make, as a preview says it, and the id the act minted. */
|
|
45
|
+
function wouldMake(store, call, author) {
|
|
46
|
+
const preview = store.previewAll([call], { author });
|
|
47
|
+
const added = preview.primitives.find((primitive) => primitive.op === "add-node");
|
|
48
|
+
return { ...(added && added.op === "add-node" ? { node: added.node } : {}), ...(preview.minted?.[0] ? { minted: preview.minted[0] } : {}) };
|
|
49
|
+
}
|
|
50
|
+
/** One call, keyed: made under its key's id, or the record made last time changed to fit. */
|
|
51
|
+
function keyed(call, key, context, basis) {
|
|
52
|
+
const store = context.store;
|
|
53
|
+
const author = context.principal;
|
|
54
|
+
let made;
|
|
55
|
+
try {
|
|
56
|
+
made = wouldMake(store, call, author);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
// Refused as it stands: the door says why, in the store's words.
|
|
60
|
+
context.change({ calls: [call], basis, key });
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (!made.node) {
|
|
64
|
+
// An act that makes nothing: run it only where it would change something.
|
|
65
|
+
if (!store.wouldChange(call, author))
|
|
66
|
+
return;
|
|
67
|
+
context.change({ calls: [call], basis, key });
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
const prefix = (made.minted ?? made.node.id).includes(":") ? (made.minted ?? made.node.id).split(":")[0] : undefined;
|
|
71
|
+
const id = prefix ? keyedId(prefix, context.workflow.name, key) : undefined;
|
|
72
|
+
const standingId = (id && store.graph.getNode(id) ? id : undefined) ?? madeUnderKey(store, context.principal.id, key);
|
|
73
|
+
const standing = standingId ? store.graph.getNode(standingId) : undefined;
|
|
74
|
+
if (standing) {
|
|
75
|
+
const changes = differing(store, made.node, standing);
|
|
76
|
+
if (Object.keys(changes).length === 0)
|
|
77
|
+
return;
|
|
78
|
+
const edit = `edit-${standing.kind}`;
|
|
79
|
+
let takes = false;
|
|
80
|
+
try {
|
|
81
|
+
const writes = store.mutation(edit).writes ?? [];
|
|
82
|
+
takes = Object.keys(changes).every((field) => writes.includes(field));
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
takes = false;
|
|
86
|
+
}
|
|
87
|
+
if (!takes)
|
|
88
|
+
return context.holdBack(`“${key}” was made by an earlier run and now differs in ${Object.keys(changes).join(", ")}, which no edit of its kind changes.`);
|
|
89
|
+
context.change({ calls: [{ name: edit, args: { id: standing.id, ...changes } }], basis: `${basis} (again, for “${key}”)`, key });
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
if ((id && everMade(store, id)) || (standingId && !standing))
|
|
93
|
+
return context.holdBack(`What it made for “${key}” was removed since; it is not made again.`);
|
|
94
|
+
// Under the key's id where the act takes one asked for; else under its own, the key kept on the lineage.
|
|
95
|
+
const asked = id ? { ...call, args: { ...call.args, id } } : call;
|
|
96
|
+
let takesId = id !== undefined;
|
|
97
|
+
if (takesId) {
|
|
98
|
+
try {
|
|
99
|
+
store.previewAll([asked], { author });
|
|
100
|
+
}
|
|
101
|
+
catch {
|
|
102
|
+
takesId = false;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
context.change({ calls: [takesId ? asked : call], basis, key });
|
|
106
|
+
}
|
|
107
|
+
export const runActStep = {
|
|
108
|
+
key: "act",
|
|
109
|
+
async run(step, context) {
|
|
110
|
+
const store = context.store;
|
|
111
|
+
const now = { at: new Date(context.now).toISOString(), today: context.today };
|
|
112
|
+
let subjectArg;
|
|
113
|
+
try {
|
|
114
|
+
subjectArg = store.mutation(step.act).subject?.arg;
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return context.skipped(`the app has no act “${step.act}”.`);
|
|
118
|
+
}
|
|
119
|
+
const ids = step.over ? recordsOver(store, step.over, context.principal) : [undefined];
|
|
120
|
+
if (step.over && ids.length === 0)
|
|
121
|
+
context.note(`Step ${context.index + 1}: no ${pluralOf(store.schema, step.over.kind).toLowerCase()} to run over.`);
|
|
122
|
+
for (const id of ids) {
|
|
123
|
+
const record = id === undefined ? undefined : store.graph.getNode(id);
|
|
124
|
+
const args = {};
|
|
125
|
+
for (const [name, value] of Object.entries(step.args ?? {}))
|
|
126
|
+
args[name] = workflowValue(value, record, store, now);
|
|
127
|
+
if (record && subjectArg && args[subjectArg] === undefined)
|
|
128
|
+
args[subjectArg] = record.id;
|
|
129
|
+
const call = { name: step.act, args };
|
|
130
|
+
const basis = `“${context.workflow.title}”${record ? ` for ${String(record["name"] ?? record.id)}` : ""}`;
|
|
131
|
+
if (step.key !== undefined)
|
|
132
|
+
keyed(call, workflowKey(step.key, { ...(record ?? {}), ...args }), context, basis);
|
|
133
|
+
else {
|
|
134
|
+
let changes = true;
|
|
135
|
+
try {
|
|
136
|
+
changes = store.wouldChange(call, context.principal);
|
|
137
|
+
}
|
|
138
|
+
catch {
|
|
139
|
+
changes = true;
|
|
140
|
+
}
|
|
141
|
+
if (changes)
|
|
142
|
+
context.change({ calls: [call], basis });
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
},
|
|
146
|
+
};
|
|
147
|
+
//# sourceMappingURL=run-act.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-act.js","sourceRoot":"","sources":["../../src/workflows/run-act.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAoG,MAAM,eAAe,CAAC;AAC3I,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAgB,MAAM,yBAAyB,CAAC;AAGzG;;;;;;;;;;;;;;;;GAgBG;AAEH,qHAAqH;AACrH,SAAS,YAAY,CAAC,KAAuB,EAAE,MAA0B,EAAE,GAAW;IACpF,KAAK,MAAM,EAAE,IAAI,CAAC,GAA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AAC,IAAI,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;YACvI,IAAI,IAAI,CAAC,GAAG,KAAK,SAAS;gBAAE,KAAK,CAAC,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC;iBAC1G,CAAC;gBACJ,IAAI,OAAO,GAAG,IAAI,CAAC;gBACnB,IAAI,CAAC;oBACH,OAAO,GAAG,KAAK,CAAC,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,SAAsB,CAAC,CAAC;gBACpE,CAAC;gBAAC,MAAM,CAAC;oBACP,OAAO,GAAG,IAAI,CAAC;gBACjB,CAAC;gBACD,IAAI,OAAO;oBAAE,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;YACxD,CAAC;QACH,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-agent.d.ts","sourceRoot":"","sources":["../../src/workflows/run-agent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAE5E,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,YAAY,CAAC;AA2B1D,eAAO,MAAM,YAAY,EAAE,UAAU,CAAC,SAAS,CAwD9C,CAAC"}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { labelOf } from "@graview/core";
|
|
2
|
+
import { mutationToolSchema } from "@graview/core/json-schema";
|
|
3
|
+
import { policyInstruction } from "@graview/core/workflows";
|
|
4
|
+
import { firstJsonObject, resolveProposal, toCall, validateProposals } from "../intelligence.js";
|
|
5
|
+
/*
|
|
6
|
+
* LET A MODEL PROPOSE (Roadmap f-job-step-types), on dreaming's terms: the
|
|
7
|
+
* model is shown the step's instruction, the records of the kinds it reads
|
|
8
|
+
* as the run's author sees them, and the acts it may propose with their
|
|
9
|
+
* input schemas — the same schemas the agent tool surface hands a seat —
|
|
10
|
+
* and answers with calls, each with how sure it is and why. A call to an
|
|
11
|
+
* act not on the list is dropped; the rest go through the run's one door,
|
|
12
|
+
* where `approve` and the confidence say what each becomes, exactly as the
|
|
13
|
+
* app's own actor's judgments are routed. One request a step unless the
|
|
14
|
+
* step's `budget.calls` says more is allowed (one is all it needs), and the
|
|
15
|
+
* records shown are cut to the step's `budget.tokens` (50,000 when unsaid).
|
|
16
|
+
* No model lent — or the host turned AI off — and the step is skipped, said
|
|
17
|
+
* on the run, which is then `partial`: never a failure. What the call spent
|
|
18
|
+
* — the reply's `usage` — is counted on the run (`spent`).
|
|
19
|
+
*/
|
|
20
|
+
const SYSTEM = [
|
|
21
|
+
"You are an automated step of an app's workflow. You read the app's records and propose changes as calls to its acts.",
|
|
22
|
+
'Answer with JSON only: {"proposals": [{"mutation": "<act>", "args": {…}, "confidence": 0.0-1.0, "why": "<one sentence>"}]}.',
|
|
23
|
+
"Propose only the acts you are given, with arguments their schemas take. Name records by their id. Propose nothing when nothing is needed.",
|
|
24
|
+
].join(" ");
|
|
25
|
+
/** A record as the model reads it: its id, kind, name and fields. */
|
|
26
|
+
const said = (store, node) => ({ id: node.id, kind: node.kind, name: labelOf(store.schema.tryDefinition(node.kind), node), ...Object.fromEntries(Object.entries(node).filter(([key]) => key !== "id" && key !== "kind" && !key.startsWith("$"))) });
|
|
27
|
+
export const runAgentStep = {
|
|
28
|
+
key: "agent",
|
|
29
|
+
async run(step, context) {
|
|
30
|
+
const complete = context.ai?.off ? undefined : context.ai?.complete;
|
|
31
|
+
if (!complete)
|
|
32
|
+
return context.skipped("no model was lent, so the model's step did not run.");
|
|
33
|
+
const seen = context.seen;
|
|
34
|
+
const tokens = step.budget?.tokens ?? 50_000;
|
|
35
|
+
const acts = step.acts.flatMap((name) => {
|
|
36
|
+
try {
|
|
37
|
+
return [mutationToolSchema(seen.mutation(name))];
|
|
38
|
+
}
|
|
39
|
+
catch {
|
|
40
|
+
return [];
|
|
41
|
+
}
|
|
42
|
+
});
|
|
43
|
+
const head = `${step.agent}${policyInstruction(context.follows)}\n\nActs you may propose:\n${JSON.stringify(acts)}\n\nRecords (${step.reads.join(", ")}):\n`;
|
|
44
|
+
const graph = seen.graph;
|
|
45
|
+
const lines = [];
|
|
46
|
+
let size = Math.ceil((SYSTEM.length + head.length) / 4);
|
|
47
|
+
let cut = 0;
|
|
48
|
+
for (const kind of step.reads) {
|
|
49
|
+
for (const node of seen.schema.tryDefinition(kind) ? graph.nodesOfKind(kind) : []) {
|
|
50
|
+
const line = JSON.stringify(said(seen, node));
|
|
51
|
+
if (size + Math.ceil(line.length / 4) > tokens) {
|
|
52
|
+
cut++;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
size += Math.ceil(line.length / 4);
|
|
56
|
+
lines.push(line);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (Math.ceil((SYSTEM.length + head.length) / 4) > tokens)
|
|
60
|
+
return context.skipped(`its instruction and acts alone are past its budget of ${tokens} tokens.`);
|
|
61
|
+
if (cut > 0)
|
|
62
|
+
context.note(`Step ${context.index + 1}: ${cut} record${cut === 1 ? " was" : "s were"} left out to keep to its budget of ${tokens} tokens.`);
|
|
63
|
+
let text;
|
|
64
|
+
const model = step.model ?? context.ai?.name ?? "model";
|
|
65
|
+
try {
|
|
66
|
+
const reply = await complete({ system: SYSTEM, prompt: `${head}${lines.join("\n")}` });
|
|
67
|
+
text = reply.text;
|
|
68
|
+
const usage = reply.usage;
|
|
69
|
+
context.spent({ calls: 1, model, ...(usage ? { inputTokens: usage.inputTokens, outputTokens: usage.outputTokens, ...(usage.costUsd !== undefined ? { costUsd: usage.costUsd } : {}) } : {}) });
|
|
70
|
+
if (usage && usage.inputTokens + usage.outputTokens > tokens)
|
|
71
|
+
context.note(`Step ${context.index + 1} spent ${usage.inputTokens + usage.outputTokens} tokens, past its budget of ${tokens}.`);
|
|
72
|
+
}
|
|
73
|
+
catch (error) {
|
|
74
|
+
context.spent({ calls: 1, model });
|
|
75
|
+
return context.skipped(`the model did not answer: ${error instanceof Error ? error.message : String(error)}`);
|
|
76
|
+
}
|
|
77
|
+
const parsed = firstJsonObject(text);
|
|
78
|
+
const raw = (Array.isArray(parsed) ? parsed : (parsed?.proposals ?? []));
|
|
79
|
+
const proposals = (Array.isArray(raw) ? raw : []).map((one) => ({ ...one, mutation: one.mutation ?? one.act ?? "" }));
|
|
80
|
+
const valid = validateProposals(seen, proposals, step.acts);
|
|
81
|
+
if (valid.length < proposals.length)
|
|
82
|
+
context.note(`Step ${context.index + 1}: ${proposals.length - valid.length} of what the model proposed named an act it may not propose, and was let go.`);
|
|
83
|
+
for (const proposal of valid) {
|
|
84
|
+
const resolved = resolveProposal(seen, proposal);
|
|
85
|
+
const sure = proposal.confidence;
|
|
86
|
+
const confidence = typeof sure === "number" ? Math.min(1, Math.max(0, sure)) : 0.5;
|
|
87
|
+
context.change({ calls: [toCall(resolved)], basis: proposal.why ?? step.agent, confidence, model });
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
//# sourceMappingURL=run-agent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-agent.js","sourceRoot":"","sources":["../../src/workflows/run-agent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAiD,MAAM,eAAe,CAAC;AACvF,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,iBAAiB,EAAkB,MAAM,yBAAyB,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,EAAE,iBAAiB,EAAqB,MAAM,oBAAoB,CAAC;AAGpH;;;;;;;;;;;;;;GAcG;AAEH,MAAM,MAAM,GAAG;IACb,s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C/L,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE,CAAC;YAC7B,MAAM,QAAQ,GAAG,eAAe,CAAC,IAAwB,EAAE,QAAQ,CAAC,CAAC;YACrE,MAAM,IAAI,GAAI,QAAqC,CAAC,UAAU,CAAC;YAC/D,MAAM,UAAU,GAAG,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;YACnF,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,KAAK,EAAE,QAAQ,CAAC,GAAG,IAAI,IAAI,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;QACtG,CAAC;IACH,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-archive.d.ts","sourceRoot":"","sources":["../../src/workflows/run-archive.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2D,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACpH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AA+C7C,eAAO,MAAM,cAAc,EAAE,UAAU,CAAC,WAAW,CA6DlD,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { ARCHIVED, isLeftAlone, nounOf, pluralOf, touchedBy } from "@graview/core";
|
|
2
|
+
import { tidyingOf } from "@graview/core/tidying";
|
|
3
|
+
import { afterMs, archiveStep, keeps, policyApplies, recordsOver } from "@graview/core/workflows";
|
|
4
|
+
/*
|
|
5
|
+
* SET ASIDE WHAT IS DONE WITH (Roadmap f-retention-rules): each live
|
|
6
|
+
* record of the kind that the step's `where` holds of, as the run's author
|
|
7
|
+
* sees it, once it has stood `after` — since it last changed, or after a
|
|
8
|
+
* date it holds — archived through its kind's own `archive-<kind>`, one
|
|
9
|
+
* change per record, every one under the run's lineage so Activity says
|
|
10
|
+
* the run as one row. Never removed; deterministic; no model.
|
|
11
|
+
*
|
|
12
|
+
* Passed by, and said: a record a person said to leave alone; every
|
|
13
|
+
* record of a kind the app says is never tidied; a record a person brought
|
|
14
|
+
* back after this workflow archived it (an undo of its archive, or "Bring
|
|
15
|
+
* it back") — never set aside again by it; and a record a rule the workflow
|
|
16
|
+
* follows keeps ("Keep …", `follows`).
|
|
17
|
+
*/
|
|
18
|
+
/** When each record last changed, by id: the time of the last op that touched it. */
|
|
19
|
+
function lastChanged(store) {
|
|
20
|
+
const at = new Map();
|
|
21
|
+
for (const op of store.log.all()) {
|
|
22
|
+
if (op.withheld)
|
|
23
|
+
continue;
|
|
24
|
+
const when = Date.parse(op.at);
|
|
25
|
+
for (const primitive of op.primitives)
|
|
26
|
+
for (const id of touchedBy(primitive))
|
|
27
|
+
at.set(id, when);
|
|
28
|
+
}
|
|
29
|
+
return at;
|
|
30
|
+
}
|
|
31
|
+
/** The records this workflow archived that a person has since brought back: an undo of its archive, or an unarchive. */
|
|
32
|
+
function broughtBack(store, actor, author) {
|
|
33
|
+
const ours = new Set();
|
|
34
|
+
const back = new Set();
|
|
35
|
+
for (const op of store.log.all()) {
|
|
36
|
+
if (op.withheld)
|
|
37
|
+
continue;
|
|
38
|
+
const mine = op.lineage?.actor === actor || (author !== undefined && op.author.id === author);
|
|
39
|
+
for (const primitive of op.primitives) {
|
|
40
|
+
if (primitive.op !== "patch-node" || !(ARCHIVED in primitive.after))
|
|
41
|
+
continue;
|
|
42
|
+
if (primitive.after[ARCHIVED] === true) {
|
|
43
|
+
if (mine)
|
|
44
|
+
ours.add(primitive.id);
|
|
45
|
+
}
|
|
46
|
+
else if (ours.has(primitive.id))
|
|
47
|
+
back.add(primitive.id);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return back;
|
|
51
|
+
}
|
|
52
|
+
const many = (count, one, more) => (count === 1 ? `one ${one}` : `${count} ${more}`);
|
|
53
|
+
export const runArchiveStep = {
|
|
54
|
+
key: "archive",
|
|
55
|
+
async run(step, context) {
|
|
56
|
+
const store = context.store;
|
|
57
|
+
const schema = store.schema;
|
|
58
|
+
const kind = step.archive;
|
|
59
|
+
if (!schema.tryDefinition(kind)) {
|
|
60
|
+
context.skipped(`"${kind}" is not a kind of this app, so nothing was archived.`);
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
if (tidyingOf(schema, kind) === "never") {
|
|
64
|
+
context.holdBack(`The app says ${pluralOf(schema, kind)} are never tidied, so none was archived.`);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
const actor = `workflow:${context.workflow.name}`;
|
|
68
|
+
const ids = recordsOver(store, { kind, ...(step.where !== undefined ? { where: step.where } : {}) }, context.principal);
|
|
69
|
+
if (ids.length === 0)
|
|
70
|
+
return;
|
|
71
|
+
const changed = lastChanged(store);
|
|
72
|
+
const first = store.log.all()[0];
|
|
73
|
+
const born = first ? Date.parse(first.at) : -Infinity;
|
|
74
|
+
const back = broughtBack(store, actor, context.principal.id);
|
|
75
|
+
const keeping = context.follows.filter(keeps);
|
|
76
|
+
const wait = typeof step.after === "string" ? afterMs(step.after) : undefined;
|
|
77
|
+
const passed = { alone: 0, back: 0, kept: [], young: 0 };
|
|
78
|
+
const basis = `${archiveStep.words(step, (one) => nounOf(schema.tryDefinition(one), one))}, in “${context.workflow.title}”`.slice(0, 500);
|
|
79
|
+
for (const id of ids) {
|
|
80
|
+
const node = store.graph.getNode(id);
|
|
81
|
+
if (!node)
|
|
82
|
+
continue;
|
|
83
|
+
if (isLeftAlone(store, id)) {
|
|
84
|
+
passed.alone++;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (back.has(id)) {
|
|
88
|
+
passed.back++;
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
const rule = keeping.find((policy) => policyApplies(policy, node, store.graph, schema, context.today));
|
|
92
|
+
if (rule) {
|
|
93
|
+
passed.kept.push(rule.label);
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
if (typeof step.after === "string") {
|
|
97
|
+
// A record no op has touched stood before the log's first: as old as that, at least.
|
|
98
|
+
const since = changed.get(id) ?? born;
|
|
99
|
+
if (wait === undefined || since === undefined || context.now - since < wait) {
|
|
100
|
+
passed.young++;
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else if (step.after) {
|
|
105
|
+
const from = Date.parse(String(node[step.after.field] ?? ""));
|
|
106
|
+
if (Number.isNaN(from) || context.now - from < step.after.days * 86_400_000) {
|
|
107
|
+
passed.young++;
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
context.change({ calls: [{ name: `archive-${kind}`, args: { id } }], basis, confidence: 1, severity: "archive" });
|
|
112
|
+
}
|
|
113
|
+
if (passed.alone > 0)
|
|
114
|
+
context.note(`Passed by ${many(passed.alone, "record", "records")} a person said to leave alone.`);
|
|
115
|
+
if (passed.back > 0)
|
|
116
|
+
context.note(`Passed by ${many(passed.back, "record", "records")} a person brought back after this workflow archived ${passed.back === 1 ? "it" : "them"}: it is not archived again.`);
|
|
117
|
+
if (passed.kept.length > 0)
|
|
118
|
+
context.note(`Kept ${many(passed.kept.length, "record", "records")} by the rule${new Set(passed.kept).size === 1 ? "" : "s"} ${[...new Set(passed.kept)].map((label) => `“${label}”`).join(", ")}.`);
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
//# sourceMappingURL=run-archive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-archive.js","sourceRoot":"","sources":["../../src/workflows/run-archive.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAmF,MAAM,eAAe,CAAC;AACpK,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,C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AI,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,KAAK,GAAG,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACnO,CAAC;CACF,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-classify.d.ts","sourceRoot":"","sources":["../../src/workflows/run-classify.ts"],"names":[],"mappings":"AACA,OAAO,EAA0D,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAKpH,OAAO,KAAK,EAAe,UAAU,EAAE,MAAM,YAAY,CAAC;AAoC1D,eAAO,MAAM,eAAe,EAAE,UAAU,CAAC,YAAY,CAwGpD,CAAC"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { isLeftAlone, labelOf, nounOf, pluralOf, withArticle } from "@graview/core";
|
|
2
|
+
import { classifyApplies, classifyAsks, floorLabel, recordsOver } from "@graview/core/workflows";
|
|
3
|
+
import { nodeState, questionsForKind } from "../questions.js";
|
|
4
|
+
import { askAll } from "../tidy/asking.js";
|
|
5
|
+
import { NONE_FITS } from "../tidy/judging.js";
|
|
6
|
+
import { choiceOf, modelWord, systemOneOf } from "../tidy/system-one.js";
|
|
7
|
+
/*
|
|
8
|
+
* LABEL EACH RECORD (Roadmap f-feedback-triage-agent), run. The records of
|
|
9
|
+
* the kind the step's `where` holds of, as the run's author sees them —
|
|
10
|
+
* those a change started the run for, when one did — less every record
|
|
11
|
+
* already labeled (unless `relabel`) and every one a person said to leave
|
|
12
|
+
* alone. Each is one request to the host's System One model (its Fast
|
|
13
|
+
* slot, or its `decide`), through dreaming's asking — a few at once,
|
|
14
|
+
* within the step's budget, answers kept by what was asked — with one
|
|
15
|
+
* Choice: which option fits, or none. Its answer is a label with how sure,
|
|
16
|
+
* set through the act that writes the field, the reason on the lineage
|
|
17
|
+
* ("Jev: 90% sure “Buy now” is spam"). Where no model answered — none
|
|
18
|
+
* lent, it failed, the budget ran out — the floor decides, sure (1), and
|
|
19
|
+
* says which rule did; a record neither labels is labeled the step's
|
|
20
|
+
* `otherwise`, when it says one, else left for a person, and the run says
|
|
21
|
+
* how many. What the model's requests spent is counted on the run
|
|
22
|
+
* (`spent`): requests, and the tokens its answers said. An option sure enough for its `setAside`
|
|
23
|
+
* threshold archives the record too, as a change of its own.
|
|
24
|
+
*
|
|
25
|
+
* Every change waits for a person unless the step says its own `approve`,
|
|
26
|
+
* or the judgment reaches its option's `applyAt` (`StepChange.apply`); an
|
|
27
|
+
* option in `confirm`, or a choice the model barely made over the next
|
|
28
|
+
* below its `applyAt`, waits whatever it says (`StepChange.ask`).
|
|
29
|
+
*/
|
|
30
|
+
/** A record's text, as the floor reads it: every string field, joined. */
|
|
31
|
+
const textOf = (node) => Object.entries(node)
|
|
32
|
+
.filter(([key, value]) => key !== "id" && key !== "kind" && !key.startsWith("$") && typeof value === "string")
|
|
33
|
+
.map(([, value]) => value)
|
|
34
|
+
.join("\n");
|
|
35
|
+
const unset = (value) => value === undefined || value === null || value === "" || (Array.isArray(value) && value.length === 0);
|
|
36
|
+
const many = (count, one, more) => (count === 1 ? `one ${one}` : `${count} ${more}`);
|
|
37
|
+
export const runClassifyStep = {
|
|
38
|
+
key: "classify",
|
|
39
|
+
async run(step, context) {
|
|
40
|
+
const { store, seen } = context;
|
|
41
|
+
const schema = store.schema;
|
|
42
|
+
const kind = step.classify;
|
|
43
|
+
const definition = schema.tryDefinition(kind);
|
|
44
|
+
if (!definition)
|
|
45
|
+
return context.skipped(`"${kind}" is not a kind of this app, so nothing was labeled.`);
|
|
46
|
+
const question = questionsForKind(seen, kind).find((one) => one.about === "field" && one.field === step.field);
|
|
47
|
+
const writes = question?.about === "field" ? question.writes : undefined;
|
|
48
|
+
if (!writes)
|
|
49
|
+
return context.skipped(`no act sets the ${step.field} of ${withArticle(nounOf(definition, kind))}, so nothing was labeled.`);
|
|
50
|
+
const options = step.options ?? (question.question.type === "choice" ? Object.keys(question.question.criteria).filter((option) => option !== NONE_FITS) : []);
|
|
51
|
+
if (options.length === 0)
|
|
52
|
+
return context.skipped(`"${step.field}" has no options to label with.`);
|
|
53
|
+
const principal = context.principal;
|
|
54
|
+
let ids = recordsOver(store, { kind, ...(step.where !== undefined ? { where: step.where } : {}) }, principal);
|
|
55
|
+
const trigger = context.trigger;
|
|
56
|
+
if ((trigger.kind === "made" || trigger.kind === "changed") && trigger.records.length > 0) {
|
|
57
|
+
const started = new Set(trigger.records);
|
|
58
|
+
ids = ids.filter((id) => started.has(id));
|
|
59
|
+
}
|
|
60
|
+
let labeled = 0;
|
|
61
|
+
let alone = 0;
|
|
62
|
+
const nodes = [];
|
|
63
|
+
for (const id of ids) {
|
|
64
|
+
const node = seen.graph.getNode(id);
|
|
65
|
+
if (!node)
|
|
66
|
+
continue;
|
|
67
|
+
if (!step.relabel && !unset(node[step.field])) {
|
|
68
|
+
labeled++;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (isLeftAlone(store, id)) {
|
|
72
|
+
alone++;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
nodes.push(node);
|
|
76
|
+
}
|
|
77
|
+
if (labeled > 0)
|
|
78
|
+
context.note(`Passed by ${many(labeled, `${nounOf(definition, kind)} already labeled`, `${pluralOf(schema, kind)} already labeled`)}: a label is never set again unless the step says relabel.`);
|
|
79
|
+
if (alone > 0)
|
|
80
|
+
context.note(`Passed by ${many(alone, "record", "records")} a person said to leave alone.`);
|
|
81
|
+
if (nodes.length === 0)
|
|
82
|
+
return;
|
|
83
|
+
const noun = nounOf(definition, kind);
|
|
84
|
+
const words = step.field.replace(/([a-z])([A-Z])/g, "$1 $2").toLowerCase();
|
|
85
|
+
const model = systemOneOf(undefined, context.ai);
|
|
86
|
+
const named = step.model ?? model?.model;
|
|
87
|
+
const judged = new Map();
|
|
88
|
+
if (model) {
|
|
89
|
+
const criteria = Object.fromEntries(options.map((option) => [option, null]));
|
|
90
|
+
criteria[NONE_FITS] = `No ${words} plainly fits; leave it for a person.`;
|
|
91
|
+
const questions = {
|
|
92
|
+
label: { type: "choice", instructions: `${step.instruction ? `${step.instruction} ` : ""}Which ${words} is this ${noun}? Choose “${NONE_FITS}” unless the record plainly says.`, criteria },
|
|
93
|
+
};
|
|
94
|
+
const asks = nodes.map((node) => ({ covers: [], state: { kind: { name: noun, ...(definition.description ? { "what it is": definition.description } : {}) }, record: nodeState(seen, node.id) ?? {} }, questions, read: () => [] }));
|
|
95
|
+
const asked = await askAll({ ...model, model: named }, asks, { budget: { requests: step.budget?.calls ?? 60, inputTokens: step.budget?.tokens ?? 200_000 } });
|
|
96
|
+
if (asked.usage.requests > 0)
|
|
97
|
+
context.spent({ calls: asked.usage.requests, inputTokens: asked.usage.inputTokens, outputTokens: asked.usage.outputTokens, ...(asked.usage.costUsd !== undefined ? { costUsd: asked.usage.costUsd } : {}), model: named });
|
|
98
|
+
if (asked.error !== undefined)
|
|
99
|
+
context.note(`Step ${context.index + 1}: the model failed (${asked.error}); the floor decided the rest.`);
|
|
100
|
+
if (asked.stopped)
|
|
101
|
+
context.note(`Step ${context.index + 1}: its budget of ${asked.stopped === "requests" ? "requests" : "tokens"} ran out; the floor decided the rest.`);
|
|
102
|
+
asked.answers.forEach((answers, at) => {
|
|
103
|
+
const chosen = choiceOf(answers?.["label"]);
|
|
104
|
+
if (!chosen || !options.includes(chosen.choice))
|
|
105
|
+
return;
|
|
106
|
+
const node = nodes[at];
|
|
107
|
+
judged.set(node.id, { option: chosen.choice, confidence: chosen.confidence, split: chosen.margin < 0.15, basis: `${modelWord(named)}: ${Math.round(chosen.confidence * 100)}% sure “${labelOf(definition, node)}” is ${chosen.choice}` });
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
else if (step.floor)
|
|
111
|
+
context.note(`Step ${context.index + 1}: no model was lent, so the floor decided.`);
|
|
112
|
+
else
|
|
113
|
+
return context.skipped("no model was lent and the step has no floor, so nothing was labeled.");
|
|
114
|
+
// The floor's rules that are rule-language lines, each read once over the kind.
|
|
115
|
+
const holding = new Map();
|
|
116
|
+
const holds = (option) => (id) => {
|
|
117
|
+
const expr = step.floor?.[option]?.expr;
|
|
118
|
+
if (expr === undefined)
|
|
119
|
+
return false;
|
|
120
|
+
if (!holding.has(option))
|
|
121
|
+
holding.set(option, new Set(recordsOver(store, { kind, where: expr }, principal)));
|
|
122
|
+
return holding.get(option).has(id);
|
|
123
|
+
};
|
|
124
|
+
let left = 0;
|
|
125
|
+
let otherwise = 0;
|
|
126
|
+
for (const node of nodes) {
|
|
127
|
+
let label = judged.get(node.id);
|
|
128
|
+
if (!label) {
|
|
129
|
+
const floor = floorLabel(step.floor, textOf(node), (option) => holds(option)(node.id));
|
|
130
|
+
if (floor && options.includes(floor.option))
|
|
131
|
+
label = { option: floor.option, confidence: 1, split: false, basis: `Sure: ${floor.basis}` };
|
|
132
|
+
}
|
|
133
|
+
if (!label && step.otherwise !== undefined && options.includes(step.otherwise)) {
|
|
134
|
+
label = { option: step.otherwise, confidence: 1, split: false, basis: `${step.otherwise}, as no option cleared it` };
|
|
135
|
+
otherwise++;
|
|
136
|
+
}
|
|
137
|
+
if (!label) {
|
|
138
|
+
left++;
|
|
139
|
+
continue;
|
|
140
|
+
}
|
|
141
|
+
const applies = classifyApplies(step, label.option, label.confidence);
|
|
142
|
+
const ask = !applies && (classifyAsks(step, label.option) || label.split);
|
|
143
|
+
const lineage = { basis: label.basis, confidence: label.confidence, ...(judged.has(node.id) && named ? { model: named } : {}) };
|
|
144
|
+
const calls = [{ name: writes.mutation, args: { [writes.subjectArg]: node.id, [writes.arg]: label.option } }];
|
|
145
|
+
context.change({ calls, ...lineage, severity: "categorize", ...(ask ? { ask: true } : applies ? { apply: true } : {}) });
|
|
146
|
+
const threshold = step.setAside?.[label.option];
|
|
147
|
+
if (threshold !== undefined && label.confidence >= threshold) {
|
|
148
|
+
context.change({ calls: [{ name: `archive-${kind}`, args: { id: node.id } }], ...lineage, basis: `${label.basis}: set aside`, severity: "archive", ...(ask ? { ask: true } : applies ? { apply: true } : {}) });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (otherwise > 0)
|
|
152
|
+
context.note(`Labeled ${many(otherwise, noun, pluralOf(schema, kind))} ${step.otherwise}: ${model ? "neither the model nor the floor" : "no floor rule"} found an option that fit.`);
|
|
153
|
+
if (left > 0)
|
|
154
|
+
context.note(`Left ${many(left, noun, pluralOf(schema, kind))} for a person: ${model ? "neither the model nor the floor" : "no floor rule"} labeled ${left === 1 ? "it" : "them"}.`);
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
//# sourceMappingURL=run-classify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-classify.js","sourceRoot":"","sources":["../../src/workflows/run-classify.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAoF,MAAM,eAAe,CAAC;AACtK,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,UAAU,EAAE,WAAW,EAAqB,MAAM,yBAAyB,CAAC;AACpH,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAiB,MAAM,iBAAiB,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGzE;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,0EAA0E;AAC1E,MAAM,MAAM,GAAG,CAAC,IAA6B,EAAU,EAAE,CACvD,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;KACjB,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,IAAI,IAAI,GAAG,KA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