@fabric-harness/sdk 6.9.0 → 6.10.1
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.d.ts.map +1 -1
- package/dist/agent.js +8 -0
- package/dist/agent.js.map +1 -1
- package/dist/channel-runtime.d.ts +2 -0
- package/dist/channel-runtime.d.ts.map +1 -1
- package/dist/channel-runtime.js +1 -0
- package/dist/channel-runtime.js.map +1 -1
- package/dist/channel.d.ts +11 -0
- package/dist/channel.d.ts.map +1 -1
- package/dist/channel.js.map +1 -1
- package/dist/context.d.ts +28 -0
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +18 -0
- package/dist/context.js.map +1 -1
- package/dist/conversation-ownership.d.ts +151 -0
- package/dist/conversation-ownership.d.ts.map +1 -0
- package/dist/conversation-ownership.js +239 -0
- package/dist/conversation-ownership.js.map +1 -0
- package/dist/dispatch.d.ts +7 -0
- package/dist/dispatch.d.ts.map +1 -1
- package/dist/dispatch.js.map +1 -1
- package/dist/dynamic-agent.d.ts.map +1 -1
- package/dist/dynamic-agent.js +8 -0
- package/dist/dynamic-agent.js.map +1 -1
- package/dist/error.d.ts +1 -1
- package/dist/error.d.ts.map +1 -1
- package/dist/error.js.map +1 -1
- package/dist/experimental.d.ts +6 -5
- package/dist/experimental.d.ts.map +1 -1
- package/dist/experimental.js +5 -3
- package/dist/experimental.js.map +1 -1
- package/dist/governed-voice.d.ts.map +1 -1
- package/dist/governed-voice.js +5 -0
- package/dist/governed-voice.js.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/loop.d.ts +8 -0
- package/dist/loop.d.ts.map +1 -1
- package/dist/loop.js +22 -1
- package/dist/loop.js.map +1 -1
- package/dist/model-pricing.js +1 -1
- package/dist/model-pricing.js.map +1 -1
- package/dist/model.d.ts +20 -2
- package/dist/model.d.ts.map +1 -1
- package/dist/model.js +88 -9
- package/dist/model.js.map +1 -1
- package/dist/persistent-agent.d.ts +1 -1
- package/dist/persistent-agent.d.ts.map +1 -1
- package/dist/persistent-agent.js.map +1 -1
- package/dist/pi-loop-runtime.d.ts.map +1 -1
- package/dist/pi-loop-runtime.js +142 -8
- package/dist/pi-loop-runtime.js.map +1 -1
- package/dist/policied-sandbox.d.ts +9 -3
- package/dist/policied-sandbox.d.ts.map +1 -1
- package/dist/policied-sandbox.js +290 -54
- package/dist/policied-sandbox.js.map +1 -1
- package/dist/policy.d.ts +3 -3
- package/dist/policy.d.ts.map +1 -1
- package/dist/policy.js +115 -64
- package/dist/policy.js.map +1 -1
- package/dist/proposal-tool.d.ts +260 -0
- package/dist/proposal-tool.d.ts.map +1 -0
- package/dist/proposal-tool.js +562 -0
- package/dist/proposal-tool.js.map +1 -0
- package/dist/sandbox-ref.d.ts +2 -2
- package/dist/sandbox-ref.d.ts.map +1 -1
- package/dist/sandbox-ref.js +143 -70
- package/dist/sandbox-ref.js.map +1 -1
- package/dist/sandbox.d.ts +8 -0
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/sandbox.js +22 -1
- package/dist/sandbox.js.map +1 -1
- package/dist/session.d.ts +71 -3
- package/dist/session.d.ts.map +1 -1
- package/dist/session.js +590 -160
- package/dist/session.js.map +1 -1
- package/dist/stop-reason-guard.d.ts +89 -0
- package/dist/stop-reason-guard.d.ts.map +1 -0
- package/dist/stop-reason-guard.js +261 -0
- package/dist/stop-reason-guard.js.map +1 -0
- package/dist/strict.d.ts +8 -1
- package/dist/strict.d.ts.map +1 -1
- package/dist/strict.js +4 -1
- package/dist/strict.js.map +1 -1
- package/dist/suspending-sandbox.d.ts +2 -2
- package/dist/suspending-sandbox.d.ts.map +1 -1
- package/dist/suspending-sandbox.js +65 -26
- package/dist/suspending-sandbox.js.map +1 -1
- package/dist/tools.d.ts +17 -3
- package/dist/tools.d.ts.map +1 -1
- package/dist/tools.js +104 -48
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +20 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/voice-pipeline.d.ts +67 -0
- package/dist/voice-pipeline.d.ts.map +1 -1
- package/dist/voice-pipeline.js +350 -20
- package/dist/voice-pipeline.js.map +1 -1
- package/dist/voice-sentences.d.ts +43 -0
- package/dist/voice-sentences.d.ts.map +1 -0
- package/dist/voice-sentences.js +99 -0
- package/dist/voice-sentences.js.map +1 -0
- package/package.json +30 -13
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sentence splitting for pipeline voice sentence streaming
|
|
3
|
+
* (`PipelineVoiceProvider({ sentenceStreaming: true })`).
|
|
4
|
+
*
|
|
5
|
+
* Deliberately small and conservative: a boundary is a run of `.`, `!` or
|
|
6
|
+
* `?` (optionally followed by closing quotes or brackets) followed by
|
|
7
|
+
* whitespace, or a run containing a CJK terminator (`。`, `!`, `?`)
|
|
8
|
+
* followed by any character. A boundary is only known once the character after
|
|
9
|
+
* the run has arrived, so a run at the end of the text stays in `rest` until
|
|
10
|
+
* more text arrives or the stream ends (`final`). A terminator followed by a
|
|
11
|
+
* non-space character (`3.5`, `v1.2`, `example.com`) is not a boundary.
|
|
12
|
+
* Abbreviations such as `Dr. Smith` do split; that only costs an extra
|
|
13
|
+
* synthesis request.
|
|
14
|
+
* @internal Not exported from the package entry points.
|
|
15
|
+
*/
|
|
16
|
+
const TERMINATORS = new Set(['.', '!', '?', '。', '!', '?']);
|
|
17
|
+
const CJK_TERMINATORS = new Set(['。', '!', '?']);
|
|
18
|
+
const CLOSERS = new Set(['"', "'", ')', ']', '}', '”', '’', '」', '』', ')', '】', '》']);
|
|
19
|
+
/**
|
|
20
|
+
* Split `text` at the sentence boundaries known so far. With `final` (the
|
|
21
|
+
* stream ended), the remaining text is a sentence too, unless it is only
|
|
22
|
+
* whitespace. Pure: the same input always gives the same output.
|
|
23
|
+
*/
|
|
24
|
+
export function splitSentences(text, final) {
|
|
25
|
+
const sentences = [];
|
|
26
|
+
let start = 0;
|
|
27
|
+
let i = 0;
|
|
28
|
+
while (i < text.length) {
|
|
29
|
+
const ch = text.charAt(i);
|
|
30
|
+
if (!TERMINATORS.has(ch)) {
|
|
31
|
+
i++;
|
|
32
|
+
continue;
|
|
33
|
+
}
|
|
34
|
+
let cjk = CJK_TERMINATORS.has(ch);
|
|
35
|
+
let end = i + 1;
|
|
36
|
+
while (end < text.length && (TERMINATORS.has(text.charAt(end)) || CLOSERS.has(text.charAt(end)))) {
|
|
37
|
+
if (CJK_TERMINATORS.has(text.charAt(end)))
|
|
38
|
+
cjk = true;
|
|
39
|
+
end++;
|
|
40
|
+
}
|
|
41
|
+
// The run reaches the end of the text: whether it ends a sentence depends on what follows.
|
|
42
|
+
if (end === text.length)
|
|
43
|
+
break;
|
|
44
|
+
if (cjk || /\s/.test(text.charAt(end))) {
|
|
45
|
+
const sentence = text.slice(start, end);
|
|
46
|
+
if (sentence.trim())
|
|
47
|
+
sentences.push(sentence);
|
|
48
|
+
start = end;
|
|
49
|
+
}
|
|
50
|
+
i = end;
|
|
51
|
+
}
|
|
52
|
+
let rest = text.slice(start);
|
|
53
|
+
if (final) {
|
|
54
|
+
if (rest.trim())
|
|
55
|
+
sentences.push(rest);
|
|
56
|
+
rest = '';
|
|
57
|
+
}
|
|
58
|
+
return { sentences, rest };
|
|
59
|
+
}
|
|
60
|
+
/** True for the first half of a UTF-16 surrogate pair. */
|
|
61
|
+
function isHighSurrogate(code) {
|
|
62
|
+
return code >= 0xd800 && code <= 0xdbff;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Cut one sentence into pieces whose text (without surrounding whitespace) is
|
|
66
|
+
* at most `max` UTF-16 code units, at the last whitespace that fits, or
|
|
67
|
+
* mid-word when a word alone is longer. A mid-word cut never falls between the
|
|
68
|
+
* two halves of a surrogate pair: that piece ends one code unit short of `max`
|
|
69
|
+
* instead (hence `max` of at least 2). The pieces concatenate to `text`;
|
|
70
|
+
* whitespace between pieces stays with the piece it precedes, and trailing
|
|
71
|
+
* whitespace with the last piece. No piece is whitespace-only; whitespace-only
|
|
72
|
+
* `text` gives none.
|
|
73
|
+
*/
|
|
74
|
+
export function cutSentence(text, max) {
|
|
75
|
+
if (!(max >= 2))
|
|
76
|
+
throw new Error('max must be at least 2');
|
|
77
|
+
const pieces = [];
|
|
78
|
+
let lead = '';
|
|
79
|
+
let rest = text;
|
|
80
|
+
while (rest) {
|
|
81
|
+
const space = /^\s*/.exec(rest)?.[0] ?? '';
|
|
82
|
+
lead += space;
|
|
83
|
+
rest = rest.slice(space.length);
|
|
84
|
+
if (!rest)
|
|
85
|
+
break;
|
|
86
|
+
let piece = rest;
|
|
87
|
+
if (rest.length > max) {
|
|
88
|
+
const cut = rest.slice(0, max + 1).search(/\s\S*$/);
|
|
89
|
+
piece = rest.slice(0, cut > 0 ? cut : max - (isHighSurrogate(rest.charCodeAt(max - 1)) ? 1 : 0));
|
|
90
|
+
}
|
|
91
|
+
pieces.push(lead + piece);
|
|
92
|
+
lead = '';
|
|
93
|
+
rest = rest.slice(piece.length);
|
|
94
|
+
}
|
|
95
|
+
if (lead && pieces.length > 0)
|
|
96
|
+
pieces[pieces.length - 1] += lead;
|
|
97
|
+
return pieces;
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=voice-sentences.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"voice-sentences.js","sourceRoot":"","sources":["../src/voice-sentences.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAC5D,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AACjD,MAAM,OAAO,GAAG,IAAI,GAAG,CAAC,CAAC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,GAAG,GAAG,EAAE,CAAC;YACtB,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACpD,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACnG,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,CAAC;QAC1B,IAAI,GAAG,EAAE,CAAC;QACV,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC;IACD,IAAI,IAAI,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,IAAI,CAAC;IACjE,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabric-harness/sdk",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.10.1",
|
|
4
4
|
"description": "Headless TypeScript framework for building durable, deployable autonomous agents — core SDK.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Fabric",
|
|
@@ -13,7 +13,16 @@
|
|
|
13
13
|
"bugs": {
|
|
14
14
|
"url": "https://github.com/Fabric-Pro/fabric-harness/issues"
|
|
15
15
|
},
|
|
16
|
-
"keywords": [
|
|
16
|
+
"keywords": [
|
|
17
|
+
"agents",
|
|
18
|
+
"ai",
|
|
19
|
+
"framework",
|
|
20
|
+
"anthropic",
|
|
21
|
+
"openai",
|
|
22
|
+
"mcp",
|
|
23
|
+
"sandbox",
|
|
24
|
+
"tool-use"
|
|
25
|
+
],
|
|
17
26
|
"type": "module",
|
|
18
27
|
"sideEffects": false,
|
|
19
28
|
"engines": {
|
|
@@ -74,19 +83,21 @@
|
|
|
74
83
|
"types": "./types/markdown.d.ts"
|
|
75
84
|
}
|
|
76
85
|
},
|
|
77
|
-
"files": [
|
|
78
|
-
|
|
79
|
-
"
|
|
80
|
-
"
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
|
|
86
|
+
"files": [
|
|
87
|
+
"dist",
|
|
88
|
+
"connector-spec",
|
|
89
|
+
"README.md",
|
|
90
|
+
"LICENSE",
|
|
91
|
+
"NOTICE",
|
|
92
|
+
"types"
|
|
93
|
+
],
|
|
84
94
|
"dependencies": {
|
|
85
|
-
"@earendil-works/pi-agent-core": "~1.
|
|
86
|
-
"@earendil-works/pi-ai": "~1.
|
|
95
|
+
"@earendil-works/pi-agent-core": "~1.5.2",
|
|
96
|
+
"@earendil-works/pi-ai": "~1.5.2",
|
|
87
97
|
"@modelcontextprotocol/sdk": "^1.32.0",
|
|
88
98
|
"@opentelemetry/api": "^1.9.1",
|
|
89
|
-
"just-bash": "^2.14.4"
|
|
99
|
+
"just-bash": "^2.14.4",
|
|
100
|
+
"typebox": "^1.3.27"
|
|
90
101
|
},
|
|
91
102
|
"peerDependencies": {
|
|
92
103
|
"ws": "^8.21.0"
|
|
@@ -100,5 +111,11 @@
|
|
|
100
111
|
"@types/ws": "^8.18.1",
|
|
101
112
|
"vitest": "^4.1.5",
|
|
102
113
|
"ws": "^8.21.0"
|
|
114
|
+
},
|
|
115
|
+
"scripts": {
|
|
116
|
+
"build": "tsc -p tsconfig.json",
|
|
117
|
+
"check": "tsc -b tsconfig.json",
|
|
118
|
+
"test": "vitest run",
|
|
119
|
+
"test:watch": "vitest"
|
|
103
120
|
}
|
|
104
|
-
}
|
|
121
|
+
}
|