@smooai/smooth-operator-core 0.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/LICENSE +21 -0
- package/dist/agent.d.ts +276 -0
- package/dist/agent.d.ts.map +1 -0
- package/dist/agent.js +450 -0
- package/dist/agent.js.map +1 -0
- package/dist/cast.d.ts +81 -0
- package/dist/cast.d.ts.map +1 -0
- package/dist/cast.js +103 -0
- package/dist/cast.js.map +1 -0
- package/dist/checkpoint.d.ts +25 -0
- package/dist/checkpoint.d.ts.map +1 -0
- package/dist/checkpoint.js +23 -0
- package/dist/checkpoint.js.map +1 -0
- package/dist/compaction.d.ts +21 -0
- package/dist/compaction.d.ts.map +1 -0
- package/dist/compaction.js +50 -0
- package/dist/compaction.js.map +1 -0
- package/dist/cost.d.ts +34 -0
- package/dist/cost.d.ts.map +1 -0
- package/dist/cost.js +42 -0
- package/dist/cost.js.map +1 -0
- package/dist/humanGate.d.ts +44 -0
- package/dist/humanGate.d.ts.map +1 -0
- package/dist/humanGate.js +30 -0
- package/dist/humanGate.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -0
- package/dist/knowledge.d.ts +30 -0
- package/dist/knowledge.d.ts.map +1 -0
- package/dist/knowledge.js +43 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/llmProvider.d.ts +106 -0
- package/dist/llmProvider.d.ts.map +1 -0
- package/dist/llmProvider.js +160 -0
- package/dist/llmProvider.js.map +1 -0
- package/dist/memory.d.ts +23 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +40 -0
- package/dist/memory.js.map +1 -0
- package/dist/rerank.d.ts +27 -0
- package/dist/rerank.d.ts.map +1 -0
- package/dist/rerank.js +45 -0
- package/dist/rerank.js.map +1 -0
- package/dist/thread.d.ts +43 -0
- package/dist/thread.d.ts.map +1 -0
- package/dist/thread.js +60 -0
- package/dist/thread.js.map +1 -0
- package/dist/toolSearch.d.ts +55 -0
- package/dist/toolSearch.d.ts.map +1 -0
- package/dist/toolSearch.js +110 -0
- package/dist/toolSearch.js.map +1 -0
- package/dist/vector.d.ts +36 -0
- package/dist/vector.d.ts.map +1 -0
- package/dist/vector.js +75 -0
- package/dist/vector.js.map +1 -0
- package/dist/workflow.d.ts +62 -0
- package/dist/workflow.d.ts.map +1 -0
- package/dist/workflow.js +109 -0
- package/dist/workflow.js.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `tool_search` meta-tool — promotes deferred tools on demand.
|
|
3
|
+
*
|
|
4
|
+
* Phase-3 sibling of the Rust reference `tool_search.rs`. Mirrors the behaviour,
|
|
5
|
+
* not the type shapes (this core has no `ToolRegistry` — tools are a plain array
|
|
6
|
+
* on {@link AgentOptions}).
|
|
7
|
+
*
|
|
8
|
+
* As a tool set grows past ~20-30 entries, every model turn pays tokens to read
|
|
9
|
+
* schemas it isn't going to use, diluting the model's attention budget. So a caller
|
|
10
|
+
* can register some tools as **deferred** (`AgentOptions.deferredTools`): their
|
|
11
|
+
* schemas are hidden from the model. Instead the agent advertises a single built-in
|
|
12
|
+
* `tool_search(query)` meta-tool. When the model calls it, this fuzzy-matches the
|
|
13
|
+
* query against the deferred tools' names + descriptions, **promotes** the matches
|
|
14
|
+
* into the visible set (so the model can call them on subsequent turns), and returns
|
|
15
|
+
* each match's name + description as JSON.
|
|
16
|
+
*
|
|
17
|
+
* A deferred tool that has not been promoted is *not* dispatchable — calling it
|
|
18
|
+
* surfaces as an unknown tool until `tool_search` adds it to the promoted set.
|
|
19
|
+
*/
|
|
20
|
+
/** The built-in meta-tool's name. Reserved when deferred tools are in play. */
|
|
21
|
+
export const TOOL_SEARCH_NAME = 'tool_search';
|
|
22
|
+
/**
|
|
23
|
+
* Cap on how many deferred tools a single `tool_search` call may promote, so a
|
|
24
|
+
* generic query like "tool" doesn't promote the entire deferred set in one shot.
|
|
25
|
+
*/
|
|
26
|
+
export const MAX_MATCHES = 8;
|
|
27
|
+
const SCHEMA = {
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties: {
|
|
30
|
+
query: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
description: 'Keyword to match against deferred tool names and descriptions. Case-insensitive substring match.',
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
required: ['query'],
|
|
36
|
+
};
|
|
37
|
+
const DESCRIPTION = 'Search for additional tools by keyword. Returns matching tool schemas as JSON; ' +
|
|
38
|
+
'matched tools become available on subsequent turns. Use when you think a tool ' +
|
|
39
|
+
"exists for a specific task but isn't in your current tool list — e.g. " +
|
|
40
|
+
'tool_search(query="git") or tool_search(query="http request").';
|
|
41
|
+
/**
|
|
42
|
+
* Drives deferred-tool promotion for one agent run. Implements {@link Tool} so the
|
|
43
|
+
* agent can advertise + dispatch it like any other tool. Holds the deferred tools
|
|
44
|
+
* (by name) and the mutable set of promoted names; the agent consults
|
|
45
|
+
* {@link promotedTools} each iteration to decide which deferred schemas are now
|
|
46
|
+
* visible/dispatchable.
|
|
47
|
+
*/
|
|
48
|
+
export class ToolSearch {
|
|
49
|
+
name = TOOL_SEARCH_NAME;
|
|
50
|
+
description = DESCRIPTION;
|
|
51
|
+
parameters = SCHEMA;
|
|
52
|
+
deferredByName;
|
|
53
|
+
promoted = new Set();
|
|
54
|
+
constructor(deferred) {
|
|
55
|
+
this.deferredByName = new Map(deferred.map((t) => [t.name, t]));
|
|
56
|
+
}
|
|
57
|
+
/** True if any tool was registered deferred (the meta-tool is advertised only then). */
|
|
58
|
+
hasDeferred() {
|
|
59
|
+
return this.deferredByName.size > 0;
|
|
60
|
+
}
|
|
61
|
+
/** True if a deferred tool has been promoted and is now dispatchable. */
|
|
62
|
+
isPromoted(name) {
|
|
63
|
+
return this.promoted.has(name);
|
|
64
|
+
}
|
|
65
|
+
/** The deferred tools that have been promoted — their schemas join the visible set. */
|
|
66
|
+
promotedTools() {
|
|
67
|
+
const out = [];
|
|
68
|
+
for (const n of this.promoted) {
|
|
69
|
+
const t = this.deferredByName.get(n);
|
|
70
|
+
if (t)
|
|
71
|
+
out.push(t);
|
|
72
|
+
}
|
|
73
|
+
return out;
|
|
74
|
+
}
|
|
75
|
+
/** Resolve a promoted deferred tool for dispatch. Unpromoted deferred tools are invisible. */
|
|
76
|
+
toolByName(name) {
|
|
77
|
+
return this.promoted.has(name) ? this.deferredByName.get(name) : undefined;
|
|
78
|
+
}
|
|
79
|
+
/** Mark a deferred tool promoted. Returns false if no such deferred tool. */
|
|
80
|
+
promote(name) {
|
|
81
|
+
if (!this.deferredByName.has(name))
|
|
82
|
+
return false;
|
|
83
|
+
this.promoted.add(name);
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
/** Fuzzy-match the query, promote matches, and return their schemas as JSON. */
|
|
87
|
+
async execute(args) {
|
|
88
|
+
const query = args.query;
|
|
89
|
+
if (typeof query !== 'string') {
|
|
90
|
+
return JSON.stringify({ matched: 0, tools: [], note: 'missing required `query` parameter' });
|
|
91
|
+
}
|
|
92
|
+
const needle = query.trim().toLowerCase();
|
|
93
|
+
if (needle.length === 0) {
|
|
94
|
+
return JSON.stringify({ matched: 0, tools: [], note: 'empty query — pass a keyword like "git" or "network"' });
|
|
95
|
+
}
|
|
96
|
+
const matched = [];
|
|
97
|
+
for (const t of this.deferredByName.values()) {
|
|
98
|
+
if (t.name.toLowerCase().includes(needle) || t.description.toLowerCase().includes(needle)) {
|
|
99
|
+
matched.push(t);
|
|
100
|
+
if (matched.length >= MAX_MATCHES)
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
for (const t of matched)
|
|
105
|
+
this.promoted.add(t.name);
|
|
106
|
+
const tools = matched.map((t) => ({ name: t.name, description: t.description, parameters: t.parameters }));
|
|
107
|
+
return JSON.stringify({ matched: tools.length, tools });
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=to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QAED,MAAM,OAAO,GAAW,EAAE,CAAC;QAC3B,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,EAAE,EAAE,CAAC;YAC3C,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,WAAW,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;gBACxF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;gBAChB,IAAI,OAAO,CAAC,MAAM,IAAI,WAAW;oBAAE,MAAM;YAC7C,CAAC;QACL,CAAC;QAED,KAAK,MAAM,CAAC,IAAI,OAAO;YAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAEnD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,WAAW,EAAE,UAAU,EAAE,CAAC,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QAC3G,OAAO,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;IAC5D,CAAC;CACJ"}
|
package/dist/vector.d.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vector knowledge — embedding-backed semantic retrieval.
|
|
3
|
+
*
|
|
4
|
+
* Phase-1 sibling of the reference engines' vector store. `VectorKnowledge` embeds
|
|
5
|
+
* documents and queries and retrieves by cosine similarity, satisfying the same
|
|
6
|
+
* {@link Knowledge} interface as the lexical retriever (so the agent accepts
|
|
7
|
+
* either). The `Embedder` is pluggable: the default `HashEmbedder` is deterministic
|
|
8
|
+
* and offline (feature-hashed bag-of-words) — good for tests and a zero-dependency
|
|
9
|
+
* default — while a gateway embedder drops in behind the same interface for true
|
|
10
|
+
* semantics.
|
|
11
|
+
*/
|
|
12
|
+
import type { Knowledge, KnowledgeHit } from './knowledge.js';
|
|
13
|
+
/** A small deterministic non-cryptographic hash (FNV-1a, 32-bit). */
|
|
14
|
+
export declare function hashToken(token: string): number;
|
|
15
|
+
export interface Embedder {
|
|
16
|
+
embed(text: string): number[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Deterministic, offline feature-hashing embedder. Hashes each token into one of
|
|
20
|
+
* `dim` buckets (signed) and L2-normalizes. No learned semantics, but a real
|
|
21
|
+
* vector with cosine geometry — docs sharing tokens land near each other.
|
|
22
|
+
*/
|
|
23
|
+
export declare class HashEmbedder implements Embedder {
|
|
24
|
+
private readonly dim;
|
|
25
|
+
constructor(dim?: number);
|
|
26
|
+
embed(text: string): number[];
|
|
27
|
+
}
|
|
28
|
+
/** An embedding-backed knowledge store with cosine-similarity retrieval. */
|
|
29
|
+
export declare class VectorKnowledge implements Knowledge {
|
|
30
|
+
private readonly embedder;
|
|
31
|
+
private readonly docs;
|
|
32
|
+
constructor(embedder?: Embedder);
|
|
33
|
+
ingest(content: string, source: string): void;
|
|
34
|
+
query(query: string, topK?: number): KnowledgeHit[];
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=vector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector.d.ts","sourceRoot":"","sources":["../src/vector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAM9D,qEAAqE;AACrE,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAO/C;AAED,MAAM,WAAW,QAAQ;IACrB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACjC;AAED;;;;GAIG;AACH,qBAAa,YAAa,YAAW,QAAQ;IAC7B,OAAO,CAAC,QAAQ,CAAC,GAAG;gBAAH,GAAG,SAAM;IAItC,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;CAWhC;AAQD,4EAA4E;AAC5E,qBAAa,eAAgB,YAAW,SAAS;IAGjC,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAFrC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAiE;gBAEzD,QAAQ,GAAE,QAA6B;IAEpE,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IAI7C,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,SAAI,GAAG,YAAY,EAAE;CASjD"}
|
package/dist/vector.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vector knowledge — embedding-backed semantic retrieval.
|
|
3
|
+
*
|
|
4
|
+
* Phase-1 sibling of the reference engines' vector store. `VectorKnowledge` embeds
|
|
5
|
+
* documents and queries and retrieves by cosine similarity, satisfying the same
|
|
6
|
+
* {@link Knowledge} interface as the lexical retriever (so the agent accepts
|
|
7
|
+
* either). The `Embedder` is pluggable: the default `HashEmbedder` is deterministic
|
|
8
|
+
* and offline (feature-hashed bag-of-words) — good for tests and a zero-dependency
|
|
9
|
+
* default — while a gateway embedder drops in behind the same interface for true
|
|
10
|
+
* semantics.
|
|
11
|
+
*/
|
|
12
|
+
function tokens(text) {
|
|
13
|
+
return text.toLowerCase().match(/[a-z0-9]+/g) ?? [];
|
|
14
|
+
}
|
|
15
|
+
/** A small deterministic non-cryptographic hash (FNV-1a, 32-bit). */
|
|
16
|
+
export function hashToken(token) {
|
|
17
|
+
let h = 0x811c9dc5;
|
|
18
|
+
for (let i = 0; i < token.length; i++) {
|
|
19
|
+
h ^= token.charCodeAt(i) & 0xff;
|
|
20
|
+
h = Math.imul(h, 0x01000193) >>> 0;
|
|
21
|
+
}
|
|
22
|
+
return h >>> 0;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Deterministic, offline feature-hashing embedder. Hashes each token into one of
|
|
26
|
+
* `dim` buckets (signed) and L2-normalizes. No learned semantics, but a real
|
|
27
|
+
* vector with cosine geometry — docs sharing tokens land near each other.
|
|
28
|
+
*/
|
|
29
|
+
export class HashEmbedder {
|
|
30
|
+
dim;
|
|
31
|
+
constructor(dim = 256) {
|
|
32
|
+
this.dim = dim;
|
|
33
|
+
if (dim <= 0)
|
|
34
|
+
throw new Error('dim must be positive');
|
|
35
|
+
}
|
|
36
|
+
embed(text) {
|
|
37
|
+
const vec = new Array(this.dim).fill(0);
|
|
38
|
+
for (const tok of tokens(text)) {
|
|
39
|
+
const h = hashToken(tok);
|
|
40
|
+
const bucket = h % this.dim;
|
|
41
|
+
const sign = (h >>> 31) & 1 ? -1 : 1;
|
|
42
|
+
vec[bucket] += sign;
|
|
43
|
+
}
|
|
44
|
+
const norm = Math.sqrt(vec.reduce((s, v) => s + v * v, 0));
|
|
45
|
+
return norm > 0 ? vec.map((v) => v / norm) : vec;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function cosine(a, b) {
|
|
49
|
+
let s = 0;
|
|
50
|
+
for (let i = 0; i < a.length; i++)
|
|
51
|
+
s += a[i] * b[i]; // both L2-normalized
|
|
52
|
+
return s;
|
|
53
|
+
}
|
|
54
|
+
/** An embedding-backed knowledge store with cosine-similarity retrieval. */
|
|
55
|
+
export class VectorKnowledge {
|
|
56
|
+
embedder;
|
|
57
|
+
docs = [];
|
|
58
|
+
constructor(embedder = new HashEmbedder()) {
|
|
59
|
+
this.embedder = embedder;
|
|
60
|
+
}
|
|
61
|
+
ingest(content, source) {
|
|
62
|
+
this.docs.push({ emb: this.embedder.embed(content), content, source });
|
|
63
|
+
}
|
|
64
|
+
query(query, topK = 4) {
|
|
65
|
+
if (topK <= 0 || this.docs.length === 0)
|
|
66
|
+
return [];
|
|
67
|
+
const q = this.embedder.embed(query);
|
|
68
|
+
return this.docs
|
|
69
|
+
.map((d) => ({ content: d.content, source: d.source, score: cosine(q, d.emb) }))
|
|
70
|
+
.filter((h) => h.score > 0)
|
|
71
|
+
.sort((a, b) => b.score - a.score)
|
|
72
|
+
.slice(0, topK);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=vector.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vector.js","sourceRoot":"","sources":["../src/vector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,SAAS,MAAM,CAAC,IAAY;IACxB,OAAO,IAAI,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;AACxD,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,SAAS,CAAC,KAAa;IACnC,IAAI,CAAC,GAAG,UAAU,CAAC;IACnB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACpC,CAAC,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;QAChC,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,CAAC,KAAK,CAAC,CAAC;AACnB,CAAC;AAMD;;;;GAIG;AACH,MAAM,OAAO,YAAY;IACQ;IAA7B,YAA6B,MAAM,GAAG;QAAT,QAAG,GAAH,GAAG,CAAM;QAClC,IAAI,GAAG,IAAI,CAAC;YAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1D,CAAC;IAED,KAAK,CAAC,IAAY;QACd,MAAM,GAAG,GAAG,IAAI,KAAK,CAAS,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChD,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,EA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Q,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC;IAC3E,CAAC;IAED,KAAK,CAAC,KAAa,EAAE,IAAI,GAAG,CAAC;QACzB,IAAI,IAAI,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QACnD,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC,IAAI;aACX,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;aAC/E,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC;aAC1B,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CAAC;aACjC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;IACxB,CAAC;CACJ"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LangGraph-inspired typed workflow graph with conditional edges.
|
|
3
|
+
*
|
|
4
|
+
* Phase-3 sibling of the reference engine's workflow primitive. A `Workflow<S>`
|
|
5
|
+
* is a state machine: **nodes** transform a typed state value and **edges** —
|
|
6
|
+
* static or **conditional** — determine the next node to execute. The runner
|
|
7
|
+
* starts at the entry node, applies each node then follows its outgoing edge,
|
|
8
|
+
* until it reaches the `END` sentinel (or a node with no outgoing edge), then
|
|
9
|
+
* returns the final state.
|
|
10
|
+
*
|
|
11
|
+
* Nodes may be sync or async; the runner awaits their results. A `maxSteps` cap
|
|
12
|
+
* bounds execution so an intentional or accidental cycle can't loop forever.
|
|
13
|
+
*
|
|
14
|
+
* Standalone module — it does not touch the agent loop. The point is the seam: a
|
|
15
|
+
* multi-step orchestration (parse → guardrails → retrieve → compose → …) drops in
|
|
16
|
+
* as a graph of named nodes with the routing made explicit.
|
|
17
|
+
*/
|
|
18
|
+
/** Sentinel a conditional router can return to signal termination. */
|
|
19
|
+
export declare const END: "__end__";
|
|
20
|
+
/** A node transforms state into a new state; may be sync or async. */
|
|
21
|
+
export type NodeFn<S> = (state: S) => S | Promise<S>;
|
|
22
|
+
/** A conditional router inspects state and returns the next node name (or `END`). */
|
|
23
|
+
export type Router<S> = (state: S) => string;
|
|
24
|
+
/** Thrown when a workflow is misconfigured or exceeds its step limit. */
|
|
25
|
+
export declare class WorkflowError extends Error {
|
|
26
|
+
constructor(message: string);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* A typed workflow graph: named nodes connected by static/conditional edges.
|
|
30
|
+
*
|
|
31
|
+
* Build with `addNode`, `addEdge` / `addConditionalEdge`, `setEntry`, and
|
|
32
|
+
* `setEnd`; the builder methods return `this` so they chain. `run` executes the
|
|
33
|
+
* graph from the entry node.
|
|
34
|
+
*/
|
|
35
|
+
export declare class Workflow<S> {
|
|
36
|
+
private readonly maxSteps;
|
|
37
|
+
private readonly nodes;
|
|
38
|
+
private readonly edges;
|
|
39
|
+
private entry;
|
|
40
|
+
constructor(maxSteps?: number);
|
|
41
|
+
/** Register a node `func` under `name` (used to reference it in edges). */
|
|
42
|
+
addNode(name: string, func: NodeFn<S>): this;
|
|
43
|
+
/** Add a static edge `from` → `to`. */
|
|
44
|
+
addEdge(from: string, to: string): this;
|
|
45
|
+
/**
|
|
46
|
+
* Add a conditional edge whose `router` picks the next node at runtime. The
|
|
47
|
+
* router returns the target node name, or `END` to terminate the workflow.
|
|
48
|
+
*/
|
|
49
|
+
addConditionalEdge(from: string, router: Router<S>): this;
|
|
50
|
+
/** Set the entry node (first node to execute). */
|
|
51
|
+
setEntry(name: string): this;
|
|
52
|
+
/** Mark `from` as terminal — reaching it ends the workflow. */
|
|
53
|
+
setEnd(from: string): this;
|
|
54
|
+
/**
|
|
55
|
+
* Execute the workflow from the entry node, returning the final state.
|
|
56
|
+
*
|
|
57
|
+
* Throws {@link WorkflowError} if no entry node was set, a referenced node
|
|
58
|
+
* does not exist, or the `maxSteps` cap is exceeded (e.g. an unbroken cycle).
|
|
59
|
+
*/
|
|
60
|
+
run(initialState: S): Promise<S>;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=workflow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.d.ts","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,sEAAsE;AACtE,eAAO,MAAM,GAAG,EAAG,SAAkB,CAAC;AAEtC,sEAAsE;AACtE,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;AAErD,qFAAqF;AACrF,MAAM,MAAM,MAAM,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;AAE7C,yEAAyE;AACzE,qBAAa,aAAc,SAAQ,KAAK;gBACxB,OAAO,EAAE,MAAM;CAI9B;AAKD;;;;;;GAMG;AACH,qBAAa,QAAQ,CAAC,CAAC;IAKP,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAJrC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAgC;IACtD,OAAO,CAAC,QAAQ,CAAC,KAAK,CAA8B;IACpD,OAAO,CAAC,KAAK,CAAqB;gBAEL,QAAQ,SAAM;IAE3C,2EAA2E;IAC3E,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI;IAK5C,uCAAuC;IACvC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI;IAKvC;;;OAGG;IACH,kBAAkB,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAAG,IAAI;IAKzD,kDAAkD;IAClD,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK5B,+DAA+D;IAC/D,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAK1B;;;;;OAKG;IACG,GAAG,CAAC,YAAY,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAmCzC"}
|
package/dist/workflow.js
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LangGraph-inspired typed workflow graph with conditional edges.
|
|
3
|
+
*
|
|
4
|
+
* Phase-3 sibling of the reference engine's workflow primitive. A `Workflow<S>`
|
|
5
|
+
* is a state machine: **nodes** transform a typed state value and **edges** —
|
|
6
|
+
* static or **conditional** — determine the next node to execute. The runner
|
|
7
|
+
* starts at the entry node, applies each node then follows its outgoing edge,
|
|
8
|
+
* until it reaches the `END` sentinel (or a node with no outgoing edge), then
|
|
9
|
+
* returns the final state.
|
|
10
|
+
*
|
|
11
|
+
* Nodes may be sync or async; the runner awaits their results. A `maxSteps` cap
|
|
12
|
+
* bounds execution so an intentional or accidental cycle can't loop forever.
|
|
13
|
+
*
|
|
14
|
+
* Standalone module — it does not touch the agent loop. The point is the seam: a
|
|
15
|
+
* multi-step orchestration (parse → guardrails → retrieve → compose → …) drops in
|
|
16
|
+
* as a graph of named nodes with the routing made explicit.
|
|
17
|
+
*/
|
|
18
|
+
/** Sentinel a conditional router can return to signal termination. */
|
|
19
|
+
export const END = '__end__';
|
|
20
|
+
/** Thrown when a workflow is misconfigured or exceeds its step limit. */
|
|
21
|
+
export class WorkflowError extends Error {
|
|
22
|
+
constructor(message) {
|
|
23
|
+
super(message);
|
|
24
|
+
this.name = 'WorkflowError';
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A typed workflow graph: named nodes connected by static/conditional edges.
|
|
29
|
+
*
|
|
30
|
+
* Build with `addNode`, `addEdge` / `addConditionalEdge`, `setEntry`, and
|
|
31
|
+
* `setEnd`; the builder methods return `this` so they chain. `run` executes the
|
|
32
|
+
* graph from the entry node.
|
|
33
|
+
*/
|
|
34
|
+
export class Workflow {
|
|
35
|
+
maxSteps;
|
|
36
|
+
nodes = new Map();
|
|
37
|
+
edges = new Map();
|
|
38
|
+
entry;
|
|
39
|
+
constructor(maxSteps = 100) {
|
|
40
|
+
this.maxSteps = maxSteps;
|
|
41
|
+
}
|
|
42
|
+
/** Register a node `func` under `name` (used to reference it in edges). */
|
|
43
|
+
addNode(name, func) {
|
|
44
|
+
this.nodes.set(name, func);
|
|
45
|
+
return this;
|
|
46
|
+
}
|
|
47
|
+
/** Add a static edge `from` → `to`. */
|
|
48
|
+
addEdge(from, to) {
|
|
49
|
+
this.edges.set(from, { kind: 'node', to });
|
|
50
|
+
return this;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Add a conditional edge whose `router` picks the next node at runtime. The
|
|
54
|
+
* router returns the target node name, or `END` to terminate the workflow.
|
|
55
|
+
*/
|
|
56
|
+
addConditionalEdge(from, router) {
|
|
57
|
+
this.edges.set(from, { kind: 'conditional', router });
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
/** Set the entry node (first node to execute). */
|
|
61
|
+
setEntry(name) {
|
|
62
|
+
this.entry = name;
|
|
63
|
+
return this;
|
|
64
|
+
}
|
|
65
|
+
/** Mark `from` as terminal — reaching it ends the workflow. */
|
|
66
|
+
setEnd(from) {
|
|
67
|
+
this.edges.set(from, { kind: 'end' });
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Execute the workflow from the entry node, returning the final state.
|
|
72
|
+
*
|
|
73
|
+
* Throws {@link WorkflowError} if no entry node was set, a referenced node
|
|
74
|
+
* does not exist, or the `maxSteps` cap is exceeded (e.g. an unbroken cycle).
|
|
75
|
+
*/
|
|
76
|
+
async run(initialState) {
|
|
77
|
+
if (this.entry === undefined) {
|
|
78
|
+
throw new WorkflowError('workflow has no entry node — call setEntry()');
|
|
79
|
+
}
|
|
80
|
+
if (!this.nodes.has(this.entry)) {
|
|
81
|
+
throw new WorkflowError(`entry node '${this.entry}' not found in registered nodes`);
|
|
82
|
+
}
|
|
83
|
+
let state = initialState;
|
|
84
|
+
let current = this.entry;
|
|
85
|
+
for (let step = 0; step < this.maxSteps; step++) {
|
|
86
|
+
const node = this.nodes.get(current);
|
|
87
|
+
if (node === undefined) {
|
|
88
|
+
throw new WorkflowError(`node '${current}' not found in workflow`);
|
|
89
|
+
}
|
|
90
|
+
state = await node(state);
|
|
91
|
+
const edge = this.edges.get(current);
|
|
92
|
+
if (edge === undefined || edge.kind === 'end') {
|
|
93
|
+
// No outgoing edge, or an explicit END — terminate.
|
|
94
|
+
return state;
|
|
95
|
+
}
|
|
96
|
+
if (edge.kind === 'conditional') {
|
|
97
|
+
const target = edge.router(state);
|
|
98
|
+
if (target === END)
|
|
99
|
+
return state;
|
|
100
|
+
current = target;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
current = edge.to;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
throw new WorkflowError(`workflow exceeded maxSteps (${this.maxSteps}) — possible infinite loop`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=workflow.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow.js","sourceRoot":"","sources":["../src/workflow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,sEAAsE;AACtE,MAAM,CAAC,MAAM,GAAG,GAAG,SAAkB,CAAC;AAQtC,yEAAyE;AACzE,MAAM,OAAO,aAAc,SAAQ,KAAK;IACpC,YAAY,OAAe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ED,MAAM,IAAI,aAAa,CAAC,+BAA+B,IAAI,CAAC,QAAQ,4BAA4B,CAAC,CAAC;IACtG,CAAC;CACJ"}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@smooai/smooth-operator-core",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Native TypeScript implementation of the smooth-operator agent engine — an in-process, OpenAI-compatible agentic tool-calling loop with knowledge grounding. The TypeScript sibling of the Rust reference engine, the C# core, and the Python core.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "git+https://github.com/SmooAI/smooth-operator-core.git",
|
|
10
|
+
"directory": "typescript/core"
|
|
11
|
+
},
|
|
12
|
+
"homepage": "https://github.com/SmooAI/smooth-operator-core/tree/main/typescript/core",
|
|
13
|
+
"sideEffects": false,
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"import": "./dist/index.js"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"openai": "^4.77.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^25.9.2",
|
|
30
|
+
"typescript": "^5.7.3",
|
|
31
|
+
"vitest": "^2.1.8"
|
|
32
|
+
},
|
|
33
|
+
"scripts": {
|
|
34
|
+
"build": "tsc -p tsconfig.build.json",
|
|
35
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
36
|
+
"test": "vitest run"
|
|
37
|
+
}
|
|
38
|
+
}
|