@unieai/rabi-spill 0.0.0-stage → 0.2.1-rc.3
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/README.md +7 -2
- package/lib/index.js +58 -0
- package/lib/types/index.d.ts +51 -0
- package/lib/types/types.d.ts +72 -0
- package/package.json +29 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 DeepSeek
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @unieai/rabi-spill
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Abstract spill storage seam (ctx.spillStore) for the Rabi Harness — save oversized tool text and return a retrieval locator
|
|
4
|
+
|
|
5
|
+
Part of Rabi, the agent harness UnieAI Code runs on. Installed as a dependency of `@unieai/rabi`;
|
|
6
|
+
not meant to be used on its own.
|
|
7
|
+
|
|
8
|
+
See LICENSE for the license and copyright of this package.
|
package/lib/index.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Service } from "@unieai/cordis";
|
|
2
|
+
//#region lib/types/types.js
|
|
3
|
+
/**
|
|
4
|
+
* Vocabulary for the spill storage Service Definition. Types only — the abstract service
|
|
5
|
+
* lives in `./index.ts`, implementations in sibling packages
|
|
6
|
+
* (`@unieai/rabi-spill-local` first).
|
|
7
|
+
*
|
|
8
|
+
* @module @unieai/rabi-spill/types
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Brand a string as a {@link SpillLocator}.
|
|
12
|
+
*
|
|
13
|
+
* @param locator The backend-produced locator string to brand.
|
|
14
|
+
* @returns The branded spill locator.
|
|
15
|
+
*/
|
|
16
|
+
function SpillLocator(locator) {
|
|
17
|
+
return locator;
|
|
18
|
+
}
|
|
19
|
+
//#endregion
|
|
20
|
+
//#region lib/types/index.js
|
|
21
|
+
/**
|
|
22
|
+
* Service Definition for the spill storage capability seam (`ctx.spillStore`): an abstract service defining WHAT a
|
|
23
|
+
* spill backend does — persist oversized text and return a model-facing
|
|
24
|
+
* locator plus retrieval guidance — without saying HOW. Implementations
|
|
25
|
+
* subclass {@link SpillStore} and register as the `spillStore` service;
|
|
26
|
+
* `@unieai/rabi-spill-local` (host filesystem) is the first.
|
|
27
|
+
*
|
|
28
|
+
* The Service Definition is deliberately minimal: `saveText` and nothing else. It owns NO
|
|
29
|
+
* retention policy (that is `@unieai/rabi-output-retention`), NO tool-result
|
|
30
|
+
* replacement (that is `@unieai/rabi-spill-policy`), and NO retrieval or
|
|
31
|
+
* search API. The backend supplies the locator and retrieval hint appropriate
|
|
32
|
+
* for its storage substrate.
|
|
33
|
+
*
|
|
34
|
+
* @module @unieai/rabi-spill
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* Abstract spill storage service. Subclass, implement {@link saveText}, and load
|
|
38
|
+
* the subclass as a plugin — it registers as `ctx.spillStore` (one
|
|
39
|
+
* implementation per context; loading a second throws, cordis' standard
|
|
40
|
+
* duplicate-service behavior).
|
|
41
|
+
*
|
|
42
|
+
* Semantics every implementation must honor:
|
|
43
|
+
* - {@link saveText} persists the FULL `content` verbatim and returns an opaque
|
|
44
|
+
* locator, exact byte length, and model-facing retrieval guidance.
|
|
45
|
+
* - Storage is scoped by the request's {@link SaveTextSpill.owner} session; the
|
|
46
|
+
* backend chooses a private (not world-readable) location and a collision-free
|
|
47
|
+
* name derived from — never equal to — the caller's `suggestedName`.
|
|
48
|
+
* - `saveText` REJECTS on a real storage failure (permissions, ENOSPC, backend
|
|
49
|
+
* unavailable); the caller decides how to degrade (the spill policy treats a
|
|
50
|
+
* rejection as best-effort and keeps the inline result).
|
|
51
|
+
*/
|
|
52
|
+
var SpillStore = class extends Service {
|
|
53
|
+
constructor(ctx) {
|
|
54
|
+
super(ctx, "spillStore");
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
58
|
+
export { SpillLocator, SpillStore, SpillStore as default };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Service Definition for the spill storage capability seam (`ctx.spillStore`): an abstract service defining WHAT a
|
|
3
|
+
* spill backend does — persist oversized text and return a model-facing
|
|
4
|
+
* locator plus retrieval guidance — without saying HOW. Implementations
|
|
5
|
+
* subclass {@link SpillStore} and register as the `spillStore` service;
|
|
6
|
+
* `@unieai/rabi-spill-local` (host filesystem) is the first.
|
|
7
|
+
*
|
|
8
|
+
* The Service Definition is deliberately minimal: `saveText` and nothing else. It owns NO
|
|
9
|
+
* retention policy (that is `@unieai/rabi-output-retention`), NO tool-result
|
|
10
|
+
* replacement (that is `@unieai/rabi-spill-policy`), and NO retrieval or
|
|
11
|
+
* search API. The backend supplies the locator and retrieval hint appropriate
|
|
12
|
+
* for its storage substrate.
|
|
13
|
+
*
|
|
14
|
+
* @module @unieai/rabi-spill
|
|
15
|
+
*/
|
|
16
|
+
import { Context, Service } from '@unieai/cordis';
|
|
17
|
+
import type { SaveTextSpill, SpillRef } from './types.ts';
|
|
18
|
+
export { SpillLocator } from './types.ts';
|
|
19
|
+
export type { SaveTextSpill, SpillOwner, SpillRef, SpillSource } from './types.ts';
|
|
20
|
+
declare module '@unieai/cordis' {
|
|
21
|
+
interface Context {
|
|
22
|
+
spillStore: SpillStore;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Abstract spill storage service. Subclass, implement {@link saveText}, and load
|
|
27
|
+
* the subclass as a plugin — it registers as `ctx.spillStore` (one
|
|
28
|
+
* implementation per context; loading a second throws, cordis' standard
|
|
29
|
+
* duplicate-service behavior).
|
|
30
|
+
*
|
|
31
|
+
* Semantics every implementation must honor:
|
|
32
|
+
* - {@link saveText} persists the FULL `content` verbatim and returns an opaque
|
|
33
|
+
* locator, exact byte length, and model-facing retrieval guidance.
|
|
34
|
+
* - Storage is scoped by the request's {@link SaveTextSpill.owner} session; the
|
|
35
|
+
* backend chooses a private (not world-readable) location and a collision-free
|
|
36
|
+
* name derived from — never equal to — the caller's `suggestedName`.
|
|
37
|
+
* - `saveText` REJECTS on a real storage failure (permissions, ENOSPC, backend
|
|
38
|
+
* unavailable); the caller decides how to degrade (the spill policy treats a
|
|
39
|
+
* rejection as best-effort and keeps the inline result).
|
|
40
|
+
*/
|
|
41
|
+
export declare abstract class SpillStore extends Service {
|
|
42
|
+
constructor(ctx: Context);
|
|
43
|
+
/**
|
|
44
|
+
* Persist `input.content` to a session-scoped spill artifact.
|
|
45
|
+
* @param input - the owner, caller-supplied source fields, suggested name, and full text to save.
|
|
46
|
+
* @returns the saved artifact's {@link SpillRef}; rejects on a storage failure.
|
|
47
|
+
*/
|
|
48
|
+
abstract saveText(input: SaveTextSpill): Promise<SpillRef>;
|
|
49
|
+
}
|
|
50
|
+
export default SpillStore;
|
|
51
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vocabulary for the spill storage Service Definition. Types only — the abstract service
|
|
3
|
+
* lives in `./index.ts`, implementations in sibling packages
|
|
4
|
+
* (`@unieai/rabi-spill-local` first).
|
|
5
|
+
*
|
|
6
|
+
* @module @unieai/rabi-spill/types
|
|
7
|
+
*/
|
|
8
|
+
import type { Branded } from '@unieai/rabi-brand';
|
|
9
|
+
import type { ToolCallId } from '@unieai/rabi-llm';
|
|
10
|
+
import type { SessionId } from '@unieai/rabi-session';
|
|
11
|
+
/**
|
|
12
|
+
* Opaque model-facing handle for one spilled artifact. A local backend may use a
|
|
13
|
+
* filesystem path; a remote or database backend may use a URI or key. Consumers
|
|
14
|
+
* render it with {@link SpillRef.retrievalHint}, but do not parse it.
|
|
15
|
+
*/
|
|
16
|
+
export type SpillLocator = Branded<'SpillLocator'>;
|
|
17
|
+
/**
|
|
18
|
+
* Brand a string as a {@link SpillLocator}.
|
|
19
|
+
*
|
|
20
|
+
* @param locator The backend-produced locator string to brand.
|
|
21
|
+
* @returns The branded spill locator.
|
|
22
|
+
*/
|
|
23
|
+
export declare function SpillLocator(locator: string): SpillLocator;
|
|
24
|
+
/**
|
|
25
|
+
* Save-time storage namespace for a spilled artifact. The session id lets a
|
|
26
|
+
* backend group storage under the producing session, but the returned
|
|
27
|
+
* {@link SpillLocator} is the model-facing handle. Forked sessions inherit
|
|
28
|
+
* locators already present in the seeded log; those artifacts are not copied or
|
|
29
|
+
* re-owned, and spills produced after the fork use the child session id.
|
|
30
|
+
*/
|
|
31
|
+
export interface SpillOwner {
|
|
32
|
+
sessionId: SessionId;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Producer of a spilled artifact. Tool results carry their model-issued call id;
|
|
36
|
+
* session references identify the captured source session instead. Descriptive
|
|
37
|
+
* source description only, never access control.
|
|
38
|
+
*/
|
|
39
|
+
export type SpillSource = {
|
|
40
|
+
kind: 'tool';
|
|
41
|
+
/** The tool whose result was spilled (e.g. `web_fetch`). */
|
|
42
|
+
toolName: string;
|
|
43
|
+
/** The model-issued call id the result belongs to. */
|
|
44
|
+
callId: ToolCallId;
|
|
45
|
+
/** A short human label for the artifact (e.g. `result`). */
|
|
46
|
+
label: string;
|
|
47
|
+
} | {
|
|
48
|
+
kind: 'session-reference';
|
|
49
|
+
/** Session whose projected conversation was captured. */
|
|
50
|
+
sessionId: SessionId;
|
|
51
|
+
/** Host-provided label for the referenced session. */
|
|
52
|
+
label: string;
|
|
53
|
+
};
|
|
54
|
+
/** One request to persist text to a spill artifact. */
|
|
55
|
+
export interface SaveTextSpill {
|
|
56
|
+
owner: SpillOwner;
|
|
57
|
+
source: SpillSource;
|
|
58
|
+
/**
|
|
59
|
+
* A caller-suggested base name (e.g. `web_fetch.txt`). The backend sanitizes
|
|
60
|
+
* it to a single safe path segment before use — it is a hint, never a path.
|
|
61
|
+
*/
|
|
62
|
+
suggestedName: string;
|
|
63
|
+
/** The full text to persist (UTF-8). */
|
|
64
|
+
content: string;
|
|
65
|
+
}
|
|
66
|
+
/** A saved spill artifact: its locator, byte length, and backend-specific retrieval guidance. */
|
|
67
|
+
export interface SpillRef {
|
|
68
|
+
locator: SpillLocator;
|
|
69
|
+
bytes: number;
|
|
70
|
+
retrievalHint: string;
|
|
71
|
+
}
|
|
72
|
+
//# sourceMappingURL=types.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,31 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unieai/rabi-spill",
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"description": "Abstract spill storage seam (ctx.spillStore) for the Rabi Harness — save oversized tool text and return a retrieval locator",
|
|
4
|
+
"version": "0.2.1-rc.3",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"type": "module",
|
|
9
|
+
"main": "lib/index.js",
|
|
10
|
+
"types": "lib/types/index.d.ts",
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./lib/types/index.d.ts",
|
|
14
|
+
"default": "./lib/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./src/*": "./src/*",
|
|
17
|
+
"./package.json": "./package.json"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"lib/index.js",
|
|
21
|
+
"lib/types/**/*.d.ts",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"@unieai/rabi-brand": "0.2.1-rc.3",
|
|
27
|
+
"@unieai/rabi-llm": "0.2.1-rc.3",
|
|
28
|
+
"@unieai/rabi-session": "0.2.1-rc.3",
|
|
29
|
+
"@unieai/cordis": "4.0.5"
|
|
30
|
+
}
|
|
31
|
+
}
|