@rcrsr/rill 0.15.0 → 0.17.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/README.md +37 -21
- package/dist/ast-nodes.d.ts +2 -13
- package/dist/ast-nodes.js +0 -1
- package/dist/ast-unions.d.ts +0 -1
- package/dist/ast-unions.js +0 -1
- package/dist/constants.d.ts +0 -1
- package/dist/constants.js +0 -1
- package/dist/error-classes.d.ts +0 -1
- package/dist/error-classes.js +0 -1
- package/dist/error-formatter.d.ts +0 -1
- package/dist/error-formatter.js +0 -1
- package/dist/error-registry.d.ts +0 -1
- package/dist/error-registry.js +32 -1
- package/dist/ext/crypto/index.d.ts +3 -4
- package/dist/ext/crypto/index.js +66 -64
- package/dist/ext/exec/index.d.ts +3 -4
- package/dist/ext/exec/index.js +17 -12
- package/dist/ext/exec/runner.d.ts +0 -1
- package/dist/ext/exec/runner.js +0 -1
- package/dist/ext/fetch/index.d.ts +3 -4
- package/dist/ext/fetch/index.js +23 -49
- package/dist/ext/fetch/request.d.ts +0 -1
- package/dist/ext/fetch/request.js +0 -1
- package/dist/ext/fs/index.d.ts +3 -4
- package/dist/ext/fs/index.js +268 -266
- package/dist/ext/fs/sandbox.d.ts +0 -1
- package/dist/ext/fs/sandbox.js +0 -1
- package/dist/ext/kv/index.d.ts +3 -4
- package/dist/ext/kv/index.js +216 -215
- package/dist/ext/kv/store.d.ts +0 -1
- package/dist/ext/kv/store.js +2 -2
- package/dist/ext-parse-bridge.d.ts +10 -0
- package/dist/ext-parse-bridge.js +10 -0
- package/dist/generated/introspection-data.d.ts +1 -2
- package/dist/generated/introspection-data.js +385 -297
- package/dist/generated/version-data.d.ts +1 -2
- package/dist/generated/version-data.js +2 -3
- package/dist/highlight-map.d.ts +0 -1
- package/dist/highlight-map.js +0 -1
- package/dist/index.d.ts +15 -5
- package/dist/index.js +14 -6
- package/dist/lexer/errors.d.ts +0 -1
- package/dist/lexer/errors.js +0 -1
- package/dist/lexer/helpers.d.ts +0 -1
- package/dist/lexer/helpers.js +0 -1
- package/dist/lexer/index.d.ts +0 -1
- package/dist/lexer/index.js +0 -1
- package/dist/lexer/operators.d.ts +0 -1
- package/dist/lexer/operators.js +0 -1
- package/dist/lexer/readers.d.ts +0 -1
- package/dist/lexer/readers.js +0 -1
- package/dist/lexer/state.d.ts +0 -1
- package/dist/lexer/state.js +0 -1
- package/dist/lexer/tokenizer.d.ts +0 -1
- package/dist/lexer/tokenizer.js +0 -1
- package/dist/parser/helpers.d.ts +0 -1
- package/dist/parser/helpers.js +0 -1
- package/dist/parser/index.d.ts +0 -1
- package/dist/parser/index.js +0 -1
- package/dist/parser/parser-collect.d.ts +0 -1
- package/dist/parser/parser-collect.js +0 -1
- package/dist/parser/parser-control.d.ts +0 -1
- package/dist/parser/parser-control.js +0 -1
- package/dist/parser/parser-expr.d.ts +0 -1
- package/dist/parser/parser-expr.js +0 -1
- package/dist/parser/parser-extract.d.ts +0 -1
- package/dist/parser/parser-extract.js +0 -1
- package/dist/parser/parser-functions.d.ts +0 -1
- package/dist/parser/parser-functions.js +0 -1
- package/dist/parser/parser-literals.d.ts +0 -1
- package/dist/parser/parser-literals.js +4 -2
- package/dist/parser/parser-script.d.ts +0 -1
- package/dist/parser/parser-script.js +0 -1
- package/dist/parser/parser-shape.d.ts +2 -3
- package/dist/parser/parser-shape.js +8 -52
- package/dist/parser/parser-types.d.ts +28 -2
- package/dist/parser/parser-types.js +76 -13
- package/dist/parser/parser-use.d.ts +0 -1
- package/dist/parser/parser-use.js +7 -2
- package/dist/parser/parser-variables.d.ts +0 -1
- package/dist/parser/parser-variables.js +0 -1
- package/dist/parser/parser.d.ts +0 -1
- package/dist/parser/parser.js +0 -1
- package/dist/parser/state.d.ts +0 -1
- package/dist/parser/state.js +0 -1
- package/dist/runtime/core/callable.d.ts +59 -20
- package/dist/runtime/core/callable.js +188 -39
- package/dist/runtime/core/context.d.ts +0 -12
- package/dist/runtime/core/context.js +77 -77
- package/dist/runtime/core/equals.d.ts +0 -1
- package/dist/runtime/core/equals.js +35 -3
- package/dist/runtime/core/eval/base.d.ts +0 -1
- package/dist/runtime/core/eval/base.js +0 -1
- package/dist/runtime/core/eval/evaluator.d.ts +0 -1
- package/dist/runtime/core/eval/evaluator.js +0 -1
- package/dist/runtime/core/eval/index.d.ts +2 -3
- package/dist/runtime/core/eval/index.js +11 -1
- package/dist/runtime/core/eval/mixins/annotations.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/annotations.js +0 -1
- package/dist/runtime/core/eval/mixins/closures.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/closures.js +92 -70
- package/dist/runtime/core/eval/mixins/collections.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/collections.js +9 -4
- package/dist/runtime/core/eval/mixins/control-flow.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/control-flow.js +0 -1
- package/dist/runtime/core/eval/mixins/conversion.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/conversion.js +196 -188
- package/dist/runtime/core/eval/mixins/core.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/core.js +2 -3
- package/dist/runtime/core/eval/mixins/expressions.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/expressions.js +35 -28
- package/dist/runtime/core/eval/mixins/extraction.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/extraction.js +8 -9
- package/dist/runtime/core/eval/mixins/list-dispatch.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/list-dispatch.js +0 -1
- package/dist/runtime/core/eval/mixins/literals.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/literals.js +6 -10
- package/dist/runtime/core/eval/mixins/types.d.ts +2 -1
- package/dist/runtime/core/eval/mixins/types.js +231 -261
- package/dist/runtime/core/eval/mixins/use.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/use.js +0 -1
- package/dist/runtime/core/eval/mixins/variables.d.ts +0 -1
- package/dist/runtime/core/eval/mixins/variables.js +16 -15
- package/dist/runtime/core/eval/types.d.ts +0 -1
- package/dist/runtime/core/eval/types.js +0 -1
- package/dist/runtime/core/execute.d.ts +0 -1
- package/dist/runtime/core/execute.js +0 -1
- package/dist/runtime/core/field-descriptor.d.ts +4 -5
- package/dist/runtime/core/field-descriptor.js +2 -2
- package/dist/runtime/core/introspection.d.ts +0 -1
- package/dist/runtime/core/introspection.js +6 -7
- package/dist/runtime/core/markers.d.ts +12 -0
- package/dist/runtime/core/markers.js +7 -0
- package/dist/runtime/core/resolvers.d.ts +0 -1
- package/dist/runtime/core/resolvers.js +0 -1
- package/dist/runtime/core/signals.d.ts +0 -1
- package/dist/runtime/core/signals.js +0 -1
- package/dist/runtime/core/type-registrations.d.ts +136 -0
- package/dist/runtime/core/type-registrations.js +749 -0
- package/dist/runtime/core/type-structures.d.ts +128 -0
- package/dist/runtime/core/type-structures.js +12 -0
- package/dist/runtime/core/types.d.ts +15 -4
- package/dist/runtime/core/types.js +0 -1
- package/dist/runtime/core/values.d.ts +88 -146
- package/dist/runtime/core/values.js +466 -470
- package/dist/runtime/ext/builtins.d.ts +0 -1
- package/dist/runtime/ext/builtins.js +125 -80
- package/dist/runtime/ext/extensions.d.ts +30 -125
- package/dist/runtime/ext/extensions.js +0 -94
- package/dist/runtime/ext/test-context.d.ts +28 -0
- package/dist/runtime/ext/test-context.js +154 -0
- package/dist/runtime/index.d.ts +22 -9
- package/dist/runtime/index.js +18 -5
- package/dist/signature-parser.d.ts +2 -3
- package/dist/signature-parser.js +19 -17
- package/dist/source-location.d.ts +0 -1
- package/dist/source-location.js +0 -1
- package/dist/token-types.d.ts +0 -1
- package/dist/token-types.js +0 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.js +0 -1
- package/dist/value-types.d.ts +15 -12
- package/dist/value-types.js +0 -1
- package/package.json +2 -1
- package/dist/ast-nodes.d.ts.map +0 -1
- package/dist/ast-nodes.js.map +0 -1
- package/dist/ast-unions.d.ts.map +0 -1
- package/dist/ast-unions.js.map +0 -1
- package/dist/constants.d.ts.map +0 -1
- package/dist/constants.js.map +0 -1
- package/dist/error-classes.d.ts.map +0 -1
- package/dist/error-classes.js.map +0 -1
- package/dist/error-formatter.d.ts.map +0 -1
- package/dist/error-formatter.js.map +0 -1
- package/dist/error-registry.d.ts.map +0 -1
- package/dist/error-registry.js.map +0 -1
- package/dist/ext/crypto/index.d.ts.map +0 -1
- package/dist/ext/crypto/index.js.map +0 -1
- package/dist/ext/exec/index.d.ts.map +0 -1
- package/dist/ext/exec/index.js.map +0 -1
- package/dist/ext/exec/runner.d.ts.map +0 -1
- package/dist/ext/exec/runner.js.map +0 -1
- package/dist/ext/fetch/index.d.ts.map +0 -1
- package/dist/ext/fetch/index.js.map +0 -1
- package/dist/ext/fetch/request.d.ts.map +0 -1
- package/dist/ext/fetch/request.js.map +0 -1
- package/dist/ext/fs/index.d.ts.map +0 -1
- package/dist/ext/fs/index.js.map +0 -1
- package/dist/ext/fs/sandbox.d.ts.map +0 -1
- package/dist/ext/fs/sandbox.js.map +0 -1
- package/dist/ext/kv/index.d.ts.map +0 -1
- package/dist/ext/kv/index.js.map +0 -1
- package/dist/ext/kv/store.d.ts.map +0 -1
- package/dist/ext/kv/store.js.map +0 -1
- package/dist/generated/introspection-data.d.ts.map +0 -1
- package/dist/generated/introspection-data.js.map +0 -1
- package/dist/generated/version-data.d.ts.map +0 -1
- package/dist/generated/version-data.js.map +0 -1
- package/dist/highlight-map.d.ts.map +0 -1
- package/dist/highlight-map.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lexer/errors.d.ts.map +0 -1
- package/dist/lexer/errors.js.map +0 -1
- package/dist/lexer/helpers.d.ts.map +0 -1
- package/dist/lexer/helpers.js.map +0 -1
- package/dist/lexer/index.d.ts.map +0 -1
- package/dist/lexer/index.js.map +0 -1
- package/dist/lexer/operators.d.ts.map +0 -1
- package/dist/lexer/operators.js.map +0 -1
- package/dist/lexer/readers.d.ts.map +0 -1
- package/dist/lexer/readers.js.map +0 -1
- package/dist/lexer/state.d.ts.map +0 -1
- package/dist/lexer/state.js.map +0 -1
- package/dist/lexer/tokenizer.d.ts.map +0 -1
- package/dist/lexer/tokenizer.js.map +0 -1
- package/dist/parser/helpers.d.ts.map +0 -1
- package/dist/parser/helpers.js.map +0 -1
- package/dist/parser/index.d.ts.map +0 -1
- package/dist/parser/index.js.map +0 -1
- package/dist/parser/parser-collect.d.ts.map +0 -1
- package/dist/parser/parser-collect.js.map +0 -1
- package/dist/parser/parser-control.d.ts.map +0 -1
- package/dist/parser/parser-control.js.map +0 -1
- package/dist/parser/parser-expr.d.ts.map +0 -1
- package/dist/parser/parser-expr.js.map +0 -1
- package/dist/parser/parser-extract.d.ts.map +0 -1
- package/dist/parser/parser-extract.js.map +0 -1
- package/dist/parser/parser-functions.d.ts.map +0 -1
- package/dist/parser/parser-functions.js.map +0 -1
- package/dist/parser/parser-literals.d.ts.map +0 -1
- package/dist/parser/parser-literals.js.map +0 -1
- package/dist/parser/parser-script.d.ts.map +0 -1
- package/dist/parser/parser-script.js.map +0 -1
- package/dist/parser/parser-shape.d.ts.map +0 -1
- package/dist/parser/parser-shape.js.map +0 -1
- package/dist/parser/parser-types.d.ts.map +0 -1
- package/dist/parser/parser-types.js.map +0 -1
- package/dist/parser/parser-use.d.ts.map +0 -1
- package/dist/parser/parser-use.js.map +0 -1
- package/dist/parser/parser-variables.d.ts.map +0 -1
- package/dist/parser/parser-variables.js.map +0 -1
- package/dist/parser/parser.d.ts.map +0 -1
- package/dist/parser/parser.js.map +0 -1
- package/dist/parser/state.d.ts.map +0 -1
- package/dist/parser/state.js.map +0 -1
- package/dist/runtime/core/callable.d.ts.map +0 -1
- package/dist/runtime/core/callable.js.map +0 -1
- package/dist/runtime/core/context.d.ts.map +0 -1
- package/dist/runtime/core/context.js.map +0 -1
- package/dist/runtime/core/equals.d.ts.map +0 -1
- package/dist/runtime/core/equals.js.map +0 -1
- package/dist/runtime/core/eval/base.d.ts.map +0 -1
- package/dist/runtime/core/eval/base.js.map +0 -1
- package/dist/runtime/core/eval/evaluator.d.ts.map +0 -1
- package/dist/runtime/core/eval/evaluator.js.map +0 -1
- package/dist/runtime/core/eval/index.d.ts.map +0 -1
- package/dist/runtime/core/eval/index.js.map +0 -1
- package/dist/runtime/core/eval/mixins/annotations.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/annotations.js.map +0 -1
- package/dist/runtime/core/eval/mixins/closures.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/closures.js.map +0 -1
- package/dist/runtime/core/eval/mixins/collections.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/collections.js.map +0 -1
- package/dist/runtime/core/eval/mixins/control-flow.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/control-flow.js.map +0 -1
- package/dist/runtime/core/eval/mixins/conversion.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/conversion.js.map +0 -1
- package/dist/runtime/core/eval/mixins/core.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/core.js.map +0 -1
- package/dist/runtime/core/eval/mixins/expressions.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/expressions.js.map +0 -1
- package/dist/runtime/core/eval/mixins/extraction.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/extraction.js.map +0 -1
- package/dist/runtime/core/eval/mixins/list-dispatch.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/list-dispatch.js.map +0 -1
- package/dist/runtime/core/eval/mixins/literals.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/literals.js.map +0 -1
- package/dist/runtime/core/eval/mixins/types.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/types.js.map +0 -1
- package/dist/runtime/core/eval/mixins/use.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/use.js.map +0 -1
- package/dist/runtime/core/eval/mixins/variables.d.ts.map +0 -1
- package/dist/runtime/core/eval/mixins/variables.js.map +0 -1
- package/dist/runtime/core/eval/types.d.ts.map +0 -1
- package/dist/runtime/core/eval/types.js.map +0 -1
- package/dist/runtime/core/execute.d.ts.map +0 -1
- package/dist/runtime/core/execute.js.map +0 -1
- package/dist/runtime/core/field-descriptor.d.ts.map +0 -1
- package/dist/runtime/core/field-descriptor.js.map +0 -1
- package/dist/runtime/core/introspection.d.ts.map +0 -1
- package/dist/runtime/core/introspection.js.map +0 -1
- package/dist/runtime/core/resolvers.d.ts.map +0 -1
- package/dist/runtime/core/resolvers.js.map +0 -1
- package/dist/runtime/core/signals.d.ts.map +0 -1
- package/dist/runtime/core/signals.js.map +0 -1
- package/dist/runtime/core/types.d.ts.map +0 -1
- package/dist/runtime/core/types.js.map +0 -1
- package/dist/runtime/core/values.d.ts.map +0 -1
- package/dist/runtime/core/values.js.map +0 -1
- package/dist/runtime/ext/builtins.d.ts.map +0 -1
- package/dist/runtime/ext/builtins.js.map +0 -1
- package/dist/runtime/ext/extensions.d.ts.map +0 -1
- package/dist/runtime/ext/extensions.js.map +0 -1
- package/dist/runtime/index.d.ts.map +0 -1
- package/dist/runtime/index.js.map +0 -1
- package/dist/signature-parser.d.ts.map +0 -1
- package/dist/signature-parser.js.map +0 -1
- package/dist/source-location.d.ts.map +0 -1
- package/dist/source-location.js.map +0 -1
- package/dist/token-types.d.ts.map +0 -1
- package/dist/token-types.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
- package/dist/value-types.d.ts.map +0 -1
- package/dist/value-types.js.map +0 -1
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
import { callable, isCallable, isDict } from '../core/callable.js';
|
|
10
10
|
import { RuntimeError } from '../../types.js';
|
|
11
11
|
import { parseSignatureRegistration } from '../../signature-parser.js';
|
|
12
|
-
import { anyTypeValue, deepEquals, formatValue, inferType, isEmpty, isRillIterator, isVector, rillTypeToTypeValue,
|
|
12
|
+
import { anyTypeValue, deepEquals, formatValue, inferType, isEmpty, isRillIterator, isVector, rillTypeToTypeValue, serializeValue, } from '../core/values.js';
|
|
13
13
|
import { invokeCallable } from '../core/eval/index.js';
|
|
14
|
+
import { populateBuiltinMethods } from '../core/type-registrations.js';
|
|
14
15
|
// ============================================================
|
|
15
16
|
// ITERATOR HELPERS
|
|
16
17
|
// ============================================================
|
|
@@ -70,26 +71,28 @@ export const BUILTIN_FUNCTIONS = {
|
|
|
70
71
|
params: [
|
|
71
72
|
{
|
|
72
73
|
name: 'value',
|
|
73
|
-
type: {
|
|
74
|
+
type: { kind: 'any' },
|
|
74
75
|
defaultValue: undefined,
|
|
75
76
|
annotations: {},
|
|
76
77
|
},
|
|
77
78
|
],
|
|
78
79
|
returnType: anyTypeValue,
|
|
79
|
-
fn: (args) => args[
|
|
80
|
+
fn: (args) => args['value'] ?? null,
|
|
80
81
|
},
|
|
81
82
|
/** Log a value and return it unchanged (passthrough) */
|
|
82
83
|
log: {
|
|
83
84
|
params: [
|
|
84
85
|
{
|
|
85
86
|
name: 'message',
|
|
86
|
-
type: {
|
|
87
|
+
type: { kind: 'any' },
|
|
87
88
|
defaultValue: undefined,
|
|
88
89
|
annotations: {},
|
|
89
90
|
},
|
|
90
91
|
],
|
|
91
92
|
returnType: anyTypeValue,
|
|
92
93
|
fn: (args, ctx) => {
|
|
94
|
+
// log is in UNTYPED_BUILTINS (allows excess args), receives positional array cast as Record.
|
|
95
|
+
// Use index 0 for the message value.
|
|
93
96
|
const value = args[0] ?? null;
|
|
94
97
|
const message = formatValue(value);
|
|
95
98
|
ctx.callbacks.onLog(message);
|
|
@@ -101,16 +104,16 @@ export const BUILTIN_FUNCTIONS = {
|
|
|
101
104
|
params: [
|
|
102
105
|
{
|
|
103
106
|
name: 'value',
|
|
104
|
-
type: {
|
|
107
|
+
type: { kind: 'any' },
|
|
105
108
|
defaultValue: undefined,
|
|
106
109
|
annotations: {},
|
|
107
110
|
},
|
|
108
111
|
],
|
|
109
|
-
returnType: rillTypeToTypeValue({
|
|
112
|
+
returnType: rillTypeToTypeValue({ kind: 'string' }),
|
|
110
113
|
fn: (args, _ctx, location) => {
|
|
111
|
-
const value = args[
|
|
114
|
+
const value = args['value'] ?? null;
|
|
112
115
|
try {
|
|
113
|
-
const jsonValue =
|
|
116
|
+
const jsonValue = serializeValue(value);
|
|
114
117
|
return JSON.stringify(jsonValue);
|
|
115
118
|
}
|
|
116
119
|
catch (err) {
|
|
@@ -133,16 +136,16 @@ export const BUILTIN_FUNCTIONS = {
|
|
|
133
136
|
{
|
|
134
137
|
name: 'items',
|
|
135
138
|
type: {
|
|
136
|
-
|
|
137
|
-
members: [{
|
|
139
|
+
kind: 'union',
|
|
140
|
+
members: [{ kind: 'list' }, { kind: 'dict' }, { kind: 'string' }],
|
|
138
141
|
},
|
|
139
142
|
defaultValue: undefined,
|
|
140
143
|
annotations: {},
|
|
141
144
|
},
|
|
142
145
|
],
|
|
143
|
-
returnType: rillTypeToTypeValue({
|
|
146
|
+
returnType: rillTypeToTypeValue({ kind: 'list' }),
|
|
144
147
|
fn: (args) => {
|
|
145
|
-
const input = args[
|
|
148
|
+
const input = args['items'] ?? null;
|
|
146
149
|
if (Array.isArray(input)) {
|
|
147
150
|
return input.map((value, index) => ({ index, value }));
|
|
148
151
|
}
|
|
@@ -165,28 +168,28 @@ export const BUILTIN_FUNCTIONS = {
|
|
|
165
168
|
params: [
|
|
166
169
|
{
|
|
167
170
|
name: 'start',
|
|
168
|
-
type: {
|
|
171
|
+
type: { kind: 'number' },
|
|
169
172
|
defaultValue: undefined,
|
|
170
173
|
annotations: {},
|
|
171
174
|
},
|
|
172
175
|
{
|
|
173
176
|
name: 'stop',
|
|
174
|
-
type: {
|
|
177
|
+
type: { kind: 'number' },
|
|
175
178
|
defaultValue: undefined,
|
|
176
179
|
annotations: {},
|
|
177
180
|
},
|
|
178
181
|
{
|
|
179
182
|
name: 'step',
|
|
180
|
-
type: {
|
|
183
|
+
type: { kind: 'number' },
|
|
181
184
|
defaultValue: 1,
|
|
182
185
|
annotations: {},
|
|
183
186
|
},
|
|
184
187
|
],
|
|
185
188
|
returnType: anyTypeValue,
|
|
186
189
|
fn: (args, _ctx, location) => {
|
|
187
|
-
const start = typeof args[
|
|
188
|
-
const end = typeof args[
|
|
189
|
-
const step = typeof args[
|
|
190
|
+
const start = typeof args['start'] === 'number' ? args['start'] : 0;
|
|
191
|
+
const end = typeof args['stop'] === 'number' ? args['stop'] : 0;
|
|
192
|
+
const step = typeof args['step'] === 'number' ? args['step'] : 1;
|
|
190
193
|
if (step === 0) {
|
|
191
194
|
throw new RuntimeError('RILL-R001', 'range step cannot be zero', location);
|
|
192
195
|
}
|
|
@@ -215,21 +218,21 @@ export const BUILTIN_FUNCTIONS = {
|
|
|
215
218
|
params: [
|
|
216
219
|
{
|
|
217
220
|
name: 'value',
|
|
218
|
-
type: {
|
|
221
|
+
type: { kind: 'any' },
|
|
219
222
|
defaultValue: undefined,
|
|
220
223
|
annotations: {},
|
|
221
224
|
},
|
|
222
225
|
{
|
|
223
226
|
name: 'count',
|
|
224
|
-
type: {
|
|
227
|
+
type: { kind: 'number' },
|
|
225
228
|
defaultValue: undefined,
|
|
226
229
|
annotations: {},
|
|
227
230
|
},
|
|
228
231
|
],
|
|
229
232
|
returnType: anyTypeValue,
|
|
230
233
|
fn: (args, _ctx, location) => {
|
|
231
|
-
const value = args[
|
|
232
|
-
const count = typeof args[
|
|
234
|
+
const value = args['value'] ?? '';
|
|
235
|
+
const count = typeof args['count'] === 'number' ? Math.floor(args['count']) : 0;
|
|
233
236
|
if (count < 0) {
|
|
234
237
|
throw new RuntimeError('RILL-R001', 'repeat count cannot be negative', location);
|
|
235
238
|
}
|
|
@@ -260,30 +263,32 @@ export const BUILTIN_FUNCTIONS = {
|
|
|
260
263
|
params: [
|
|
261
264
|
{
|
|
262
265
|
name: 'value',
|
|
263
|
-
type: {
|
|
266
|
+
type: { kind: 'any' },
|
|
264
267
|
defaultValue: undefined,
|
|
265
268
|
annotations: {},
|
|
266
269
|
},
|
|
267
270
|
{
|
|
268
271
|
name: 'transform',
|
|
269
|
-
type: {
|
|
272
|
+
type: { kind: 'any' },
|
|
270
273
|
defaultValue: undefined,
|
|
271
274
|
annotations: {},
|
|
272
275
|
},
|
|
273
276
|
],
|
|
274
277
|
returnType: anyTypeValue,
|
|
275
278
|
fn: async (args, ctx, location) => {
|
|
279
|
+
// chain is in UNTYPED_BUILTINS, receives positional array cast as Record.
|
|
276
280
|
// Pipe position: 5 -> chain($closure) sends args=[$closure] with pipeValue=5.
|
|
277
281
|
// Detect this by checking if there is exactly one arg and a pipe value is set.
|
|
282
|
+
const positional = args;
|
|
278
283
|
let value;
|
|
279
284
|
let arg;
|
|
280
|
-
if (
|
|
285
|
+
if (positional.length === 1 && ctx.pipeValue !== null) {
|
|
281
286
|
value = ctx.pipeValue;
|
|
282
|
-
arg =
|
|
287
|
+
arg = positional[0] ?? null;
|
|
283
288
|
}
|
|
284
289
|
else {
|
|
285
|
-
value =
|
|
286
|
-
arg =
|
|
290
|
+
value = positional[0] ?? null;
|
|
291
|
+
arg = positional[1] ?? null;
|
|
287
292
|
}
|
|
288
293
|
if (Array.isArray(arg)) {
|
|
289
294
|
// List of closures: fold left-to-right
|
|
@@ -307,33 +312,47 @@ export const BUILTIN_FUNCTIONS = {
|
|
|
307
312
|
// ============================================================
|
|
308
313
|
// BUILT-IN METHODS
|
|
309
314
|
// ============================================================
|
|
310
|
-
/**
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
return compare(formatValue(receiver), formatValue(arg ?? ''));
|
|
318
|
-
};
|
|
319
|
-
}
|
|
315
|
+
/** Receiver param prepended to every method's param list */
|
|
316
|
+
const RECEIVER_PARAM = {
|
|
317
|
+
name: 'receiver',
|
|
318
|
+
type: { kind: 'any' },
|
|
319
|
+
defaultValue: undefined,
|
|
320
|
+
annotations: {},
|
|
321
|
+
};
|
|
320
322
|
/**
|
|
321
323
|
* Build a RillFunction entry from a method body and its signature string.
|
|
322
324
|
* Wraps `method(receiver, args, ctx, location)` as `fn(args, ctx, location)`
|
|
323
|
-
* where
|
|
324
|
-
* returnType so that task 1.4
|
|
325
|
+
* where receiver is the first param by declaration order (named 'receiver').
|
|
326
|
+
* Parses the signature to extract params and returnType so that task 1.4
|
|
327
|
+
* can use them directly without re-parsing.
|
|
328
|
+
*
|
|
329
|
+
* EC-4: Receiver missing from record raises RILL-R044.
|
|
325
330
|
*/
|
|
326
|
-
function buildMethodEntry(name, signature, method) {
|
|
331
|
+
function buildMethodEntry(name, signature, method, skipReceiverValidation) {
|
|
327
332
|
const parsed = parseSignatureRegistration(signature, name);
|
|
333
|
+
const methodParams = parsed.params;
|
|
328
334
|
return {
|
|
329
|
-
params:
|
|
330
|
-
fn: (args, ctx, location) =>
|
|
335
|
+
params: [RECEIVER_PARAM, ...methodParams],
|
|
336
|
+
fn: (args, ctx, location) => {
|
|
337
|
+
if (!('receiver' in args)) {
|
|
338
|
+
throw new RuntimeError('RILL-R044', "Missing required parameter 'receiver'", location);
|
|
339
|
+
}
|
|
340
|
+
const receiver = args['receiver'] ?? null;
|
|
341
|
+
// Reconstruct positional args array for RillMethod from named params in order.
|
|
342
|
+
// UNVALIDATED_METHOD_PARAMS methods pass __positionalArgs to preserve actual
|
|
343
|
+
// arg count so method body arity checks (args.length !== 1) fire correctly.
|
|
344
|
+
const positionalArgs = '__positionalArgs' in args
|
|
345
|
+
? args['__positionalArgs']
|
|
346
|
+
: methodParams.map((p) => args[p.name] ?? null);
|
|
347
|
+
return method(receiver, positionalArgs, ctx, location);
|
|
348
|
+
},
|
|
331
349
|
annotations: parsed.description !== undefined
|
|
332
350
|
? { description: parsed.description }
|
|
333
351
|
: {},
|
|
334
352
|
returnType: parsed.returnType !== undefined
|
|
335
353
|
? rillTypeToTypeValue(parsed.returnType)
|
|
336
354
|
: anyTypeValue,
|
|
355
|
+
...(skipReceiverValidation ? { skipReceiverValidation: true } : {}),
|
|
337
356
|
};
|
|
338
357
|
}
|
|
339
358
|
export const BUILTIN_METHODS = {
|
|
@@ -525,10 +544,34 @@ const mPadEnd = (receiver, args) => {
|
|
|
525
544
|
const mEq = (receiver, args) => deepEquals(receiver, args[0] ?? null);
|
|
526
545
|
/** Inequality check (deep structural comparison) */
|
|
527
546
|
const mNe = (receiver, args) => !deepEquals(receiver, args[0] ?? null);
|
|
528
|
-
|
|
529
|
-
const
|
|
530
|
-
const
|
|
531
|
-
|
|
547
|
+
/** Less-than comparison (number or string) */
|
|
548
|
+
const mLt = (receiver, args) => {
|
|
549
|
+
const arg = args[0];
|
|
550
|
+
if (typeof receiver === 'number' && typeof arg === 'number')
|
|
551
|
+
return receiver < arg;
|
|
552
|
+
return formatValue(receiver) < formatValue(arg ?? '');
|
|
553
|
+
};
|
|
554
|
+
/** Greater-than comparison (number or string) */
|
|
555
|
+
const mGt = (receiver, args) => {
|
|
556
|
+
const arg = args[0];
|
|
557
|
+
if (typeof receiver === 'number' && typeof arg === 'number')
|
|
558
|
+
return receiver > arg;
|
|
559
|
+
return formatValue(receiver) > formatValue(arg ?? '');
|
|
560
|
+
};
|
|
561
|
+
/** Less-than-or-equal comparison (number or string) */
|
|
562
|
+
const mLe = (receiver, args) => {
|
|
563
|
+
const arg = args[0];
|
|
564
|
+
if (typeof receiver === 'number' && typeof arg === 'number')
|
|
565
|
+
return receiver <= arg;
|
|
566
|
+
return formatValue(receiver) <= formatValue(arg ?? '');
|
|
567
|
+
};
|
|
568
|
+
/** Greater-than-or-equal comparison (number or string) */
|
|
569
|
+
const mGe = (receiver, args) => {
|
|
570
|
+
const arg = args[0];
|
|
571
|
+
if (typeof receiver === 'number' && typeof arg === 'number')
|
|
572
|
+
return receiver >= arg;
|
|
573
|
+
return formatValue(receiver) >= formatValue(arg ?? '');
|
|
574
|
+
};
|
|
532
575
|
/** Get all keys of a dict as a list */
|
|
533
576
|
const mKeys = (receiver) => isDict(receiver) ? Object.keys(receiver) : [];
|
|
534
577
|
/** Get all values of a dict as a list */
|
|
@@ -730,10 +773,10 @@ const SIG_CMP = '|other: any|:bool';
|
|
|
730
773
|
BUILTIN_METHODS.string = Object.freeze({
|
|
731
774
|
len: buildMethodEntry('len', SIG_LEN, mLen),
|
|
732
775
|
trim: buildMethodEntry('trim', '||:string', mTrim),
|
|
733
|
-
head: buildMethodEntry('head', SIG_HEAD, mHead),
|
|
734
|
-
tail: buildMethodEntry('tail', SIG_TAIL, mTail),
|
|
735
|
-
first: buildMethodEntry('first', SIG_FIRST, mFirst),
|
|
736
|
-
at: buildMethodEntry('at', SIG_AT, mAt),
|
|
776
|
+
head: buildMethodEntry('head', SIG_HEAD, mHead, true),
|
|
777
|
+
tail: buildMethodEntry('tail', SIG_TAIL, mTail, true),
|
|
778
|
+
first: buildMethodEntry('first', SIG_FIRST, mFirst, true),
|
|
779
|
+
at: buildMethodEntry('at', SIG_AT, mAt, true),
|
|
737
780
|
split: buildMethodEntry('split', '|separator: string = "\\n"|:list', mSplit),
|
|
738
781
|
lines: buildMethodEntry('lines', '||:list', mLines),
|
|
739
782
|
empty: buildMethodEntry('empty', SIG_EMPTY, mEmpty),
|
|
@@ -750,8 +793,8 @@ BUILTIN_METHODS.string = Object.freeze({
|
|
|
750
793
|
repeat: buildMethodEntry('repeat', '|count: number|:string', mRepeat),
|
|
751
794
|
pad_start: buildMethodEntry('pad_start', '|length: number, fill: string = " "|:string', mPadStart),
|
|
752
795
|
pad_end: buildMethodEntry('pad_end', '|length: number, fill: string = " "|:string', mPadEnd),
|
|
753
|
-
eq: buildMethodEntry('eq', SIG_EQ, mEq),
|
|
754
|
-
ne: buildMethodEntry('ne', SIG_NE, mNe),
|
|
796
|
+
eq: buildMethodEntry('eq', SIG_EQ, mEq, true),
|
|
797
|
+
ne: buildMethodEntry('ne', SIG_NE, mNe, true),
|
|
755
798
|
lt: buildMethodEntry('lt', SIG_CMP, mLt),
|
|
756
799
|
gt: buildMethodEntry('gt', SIG_CMP, mGt),
|
|
757
800
|
le: buildMethodEntry('le', SIG_CMP, mLe),
|
|
@@ -759,32 +802,32 @@ BUILTIN_METHODS.string = Object.freeze({
|
|
|
759
802
|
});
|
|
760
803
|
BUILTIN_METHODS.list = Object.freeze({
|
|
761
804
|
len: buildMethodEntry('len', SIG_LEN, mLen),
|
|
762
|
-
head: buildMethodEntry('head', SIG_HEAD, mHead),
|
|
763
|
-
tail: buildMethodEntry('tail', SIG_TAIL, mTail),
|
|
764
|
-
first: buildMethodEntry('first', SIG_FIRST, mFirst),
|
|
765
|
-
at: buildMethodEntry('at', SIG_AT, mAt),
|
|
805
|
+
head: buildMethodEntry('head', SIG_HEAD, mHead, true),
|
|
806
|
+
tail: buildMethodEntry('tail', SIG_TAIL, mTail, true),
|
|
807
|
+
first: buildMethodEntry('first', SIG_FIRST, mFirst, true),
|
|
808
|
+
at: buildMethodEntry('at', SIG_AT, mAt, true),
|
|
766
809
|
join: buildMethodEntry('join', '|separator: string = ","|:string', mJoin),
|
|
767
810
|
empty: buildMethodEntry('empty', SIG_EMPTY, mEmpty),
|
|
768
|
-
eq: buildMethodEntry('eq', SIG_EQ, mEq),
|
|
769
|
-
ne: buildMethodEntry('ne', SIG_NE, mNe),
|
|
770
|
-
has: buildMethodEntry('has', '|value: any|:bool', mHas),
|
|
771
|
-
has_any: buildMethodEntry('has_any', '|candidates: list|:bool', mHasAny),
|
|
772
|
-
has_all: buildMethodEntry('has_all', '|candidates: list|:bool', mHasAll),
|
|
811
|
+
eq: buildMethodEntry('eq', SIG_EQ, mEq, true),
|
|
812
|
+
ne: buildMethodEntry('ne', SIG_NE, mNe, true),
|
|
813
|
+
has: buildMethodEntry('has', '|value: any|:bool', mHas, true),
|
|
814
|
+
has_any: buildMethodEntry('has_any', '|candidates: list|:bool', mHasAny, true),
|
|
815
|
+
has_all: buildMethodEntry('has_all', '|candidates: list|:bool', mHasAll, true),
|
|
773
816
|
});
|
|
774
817
|
BUILTIN_METHODS.dict = Object.freeze({
|
|
775
818
|
len: buildMethodEntry('len', SIG_LEN, mLen),
|
|
776
|
-
first: buildMethodEntry('first', SIG_FIRST, mFirst),
|
|
819
|
+
first: buildMethodEntry('first', SIG_FIRST, mFirst, true),
|
|
777
820
|
empty: buildMethodEntry('empty', SIG_EMPTY, mEmpty),
|
|
778
|
-
eq: buildMethodEntry('eq', SIG_EQ, mEq),
|
|
779
|
-
ne: buildMethodEntry('ne', SIG_NE, mNe),
|
|
780
|
-
keys: buildMethodEntry('keys', '||:list', mKeys),
|
|
781
|
-
values: buildMethodEntry('values', '||:list', mValues),
|
|
782
|
-
entries: buildMethodEntry('entries', '||:list', mEntries),
|
|
821
|
+
eq: buildMethodEntry('eq', SIG_EQ, mEq, true),
|
|
822
|
+
ne: buildMethodEntry('ne', SIG_NE, mNe, true),
|
|
823
|
+
keys: buildMethodEntry('keys', '||:list', mKeys, true),
|
|
824
|
+
values: buildMethodEntry('values', '||:list', mValues, true),
|
|
825
|
+
entries: buildMethodEntry('entries', '||:list', mEntries, true),
|
|
783
826
|
});
|
|
784
827
|
BUILTIN_METHODS.number = Object.freeze({
|
|
785
828
|
empty: buildMethodEntry('empty', SIG_EMPTY, mEmpty),
|
|
786
|
-
eq: buildMethodEntry('eq', SIG_EQ, mEq),
|
|
787
|
-
ne: buildMethodEntry('ne', SIG_NE, mNe),
|
|
829
|
+
eq: buildMethodEntry('eq', SIG_EQ, mEq, true),
|
|
830
|
+
ne: buildMethodEntry('ne', SIG_NE, mNe, true),
|
|
788
831
|
lt: buildMethodEntry('lt', SIG_CMP, mLt),
|
|
789
832
|
gt: buildMethodEntry('gt', SIG_CMP, mGt),
|
|
790
833
|
le: buildMethodEntry('le', SIG_CMP, mLe),
|
|
@@ -792,19 +835,21 @@ BUILTIN_METHODS.number = Object.freeze({
|
|
|
792
835
|
});
|
|
793
836
|
BUILTIN_METHODS.bool = Object.freeze({
|
|
794
837
|
empty: buildMethodEntry('empty', SIG_EMPTY, mEmpty),
|
|
795
|
-
eq: buildMethodEntry('eq', SIG_EQ, mEq),
|
|
796
|
-
ne: buildMethodEntry('ne', SIG_NE, mNe),
|
|
838
|
+
eq: buildMethodEntry('eq', SIG_EQ, mEq, true),
|
|
839
|
+
ne: buildMethodEntry('ne', SIG_NE, mNe, true),
|
|
797
840
|
});
|
|
798
841
|
// [ASSUMPTION] vector is a 6th group beyond the 5 specified basic types.
|
|
799
842
|
// The 7 vector methods do not belong to string/list/dict/number/bool.
|
|
800
843
|
// Adding this group ensures all 42 methods are accessible (AC-36).
|
|
801
844
|
BUILTIN_METHODS.vector = Object.freeze({
|
|
802
|
-
dimensions: buildMethodEntry('dimensions', '||:number', mDimensions),
|
|
803
|
-
model: buildMethodEntry('model', '||:string', mModel),
|
|
804
|
-
similarity: buildMethodEntry('similarity', '|other: any|:number', mSimilarity),
|
|
805
|
-
dot: buildMethodEntry('dot', '|other: any|:number', mDot),
|
|
806
|
-
distance: buildMethodEntry('distance', '|other: any|:number', mDistance),
|
|
807
|
-
norm: buildMethodEntry('norm', '||:number', mNorm),
|
|
808
|
-
normalize: buildMethodEntry('normalize', '||:any', mNormalize),
|
|
845
|
+
dimensions: buildMethodEntry('dimensions', '||:number', mDimensions, true),
|
|
846
|
+
model: buildMethodEntry('model', '||:string', mModel, true),
|
|
847
|
+
similarity: buildMethodEntry('similarity', '|other: any|:number', mSimilarity, true),
|
|
848
|
+
dot: buildMethodEntry('dot', '|other: any|:number', mDot, true),
|
|
849
|
+
distance: buildMethodEntry('distance', '|other: any|:number', mDistance, true),
|
|
850
|
+
norm: buildMethodEntry('norm', '||:number', mNorm, true),
|
|
851
|
+
normalize: buildMethodEntry('normalize', '||:any', mNormalize, true),
|
|
809
852
|
});
|
|
810
|
-
|
|
853
|
+
// Populate registration methods from BUILTIN_METHODS at module load time.
|
|
854
|
+
// No circular dependency: type-registrations.ts does not import builtins.ts.
|
|
855
|
+
populateBuiltinMethods(BUILTIN_METHODS);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ApplicationCallable } from '../core/callable.js';
|
|
2
2
|
import type { ExtensionEvent, RuntimeCallbacks } from '../core/types.js';
|
|
3
|
+
import type { RillValue } from '../core/values.js';
|
|
3
4
|
/**
|
|
4
5
|
* Minimal interface for extension event emission.
|
|
5
6
|
* Allows emitExtensionEvent to accept any context with callbacks.
|
|
@@ -9,27 +10,20 @@ interface RuntimeContextLike {
|
|
|
9
10
|
}
|
|
10
11
|
/**
|
|
11
12
|
* Result object returned by extension factories.
|
|
12
|
-
* Contains
|
|
13
|
+
* Contains the mounted RillValue with optional lifecycle hooks.
|
|
14
|
+
* Lifecycle hooks live on the factory result, not on the value dict (DD-1).
|
|
13
15
|
*/
|
|
14
|
-
export interface
|
|
15
|
-
|
|
16
|
+
export interface ExtensionFactoryResult {
|
|
17
|
+
readonly value: RillValue;
|
|
16
18
|
dispose?: () => void | Promise<void>;
|
|
17
19
|
suspend?: () => unknown;
|
|
18
20
|
restore?: (state: unknown) => void;
|
|
19
21
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Result object returned by hoistExtension.
|
|
22
|
-
* Separates functions from dispose for safe createRuntimeContext usage.
|
|
23
|
-
*/
|
|
24
|
-
export interface HoistedExtension {
|
|
25
|
-
functions: Record<string, RillFunction>;
|
|
26
|
-
dispose?: () => void | Promise<void>;
|
|
27
|
-
}
|
|
28
22
|
/**
|
|
29
23
|
* Factory function contract for creating extensions.
|
|
30
24
|
* Accepts typed configuration and returns isolated instance.
|
|
31
25
|
*/
|
|
32
|
-
export type ExtensionFactory<TConfig> = (config: TConfig) =>
|
|
26
|
+
export type ExtensionFactory<TConfig> = (config: TConfig) => ExtensionFactoryResult | Promise<ExtensionFactoryResult>;
|
|
33
27
|
/**
|
|
34
28
|
* Descriptor for a single configuration field in an extension schema.
|
|
35
29
|
* The secret flag is advisory: harness tooling uses it to mask or omit values.
|
|
@@ -72,18 +66,17 @@ export interface ExtensionManifest {
|
|
|
72
66
|
* - mounts(): List all configured mounts
|
|
73
67
|
*/
|
|
74
68
|
export type KvExtensionContract = {
|
|
75
|
-
readonly get:
|
|
76
|
-
readonly get_or:
|
|
77
|
-
readonly set:
|
|
78
|
-
readonly merge:
|
|
79
|
-
readonly delete:
|
|
80
|
-
readonly keys:
|
|
81
|
-
readonly has:
|
|
82
|
-
readonly clear:
|
|
83
|
-
readonly getAll:
|
|
84
|
-
readonly schema:
|
|
85
|
-
readonly mounts:
|
|
86
|
-
readonly dispose?: (() => void | Promise<void>) | undefined;
|
|
69
|
+
readonly get: ApplicationCallable;
|
|
70
|
+
readonly get_or: ApplicationCallable;
|
|
71
|
+
readonly set: ApplicationCallable;
|
|
72
|
+
readonly merge: ApplicationCallable;
|
|
73
|
+
readonly delete: ApplicationCallable;
|
|
74
|
+
readonly keys: ApplicationCallable;
|
|
75
|
+
readonly has: ApplicationCallable;
|
|
76
|
+
readonly clear: ApplicationCallable;
|
|
77
|
+
readonly getAll: ApplicationCallable;
|
|
78
|
+
readonly schema: ApplicationCallable;
|
|
79
|
+
readonly mounts: ApplicationCallable;
|
|
87
80
|
};
|
|
88
81
|
/**
|
|
89
82
|
* Contract type for fs extension implementations.
|
|
@@ -104,106 +97,19 @@ export type KvExtensionContract = {
|
|
|
104
97
|
* - mounts(): List all configured mounts
|
|
105
98
|
*/
|
|
106
99
|
export type FsExtensionContract = {
|
|
107
|
-
readonly read:
|
|
108
|
-
readonly write:
|
|
109
|
-
readonly append:
|
|
110
|
-
readonly list:
|
|
111
|
-
readonly find:
|
|
112
|
-
readonly exists:
|
|
113
|
-
readonly remove:
|
|
114
|
-
readonly stat:
|
|
115
|
-
readonly mkdir:
|
|
116
|
-
readonly copy:
|
|
117
|
-
readonly move:
|
|
118
|
-
readonly mounts:
|
|
119
|
-
readonly dispose?: (() => void | Promise<void>) | undefined;
|
|
120
|
-
};
|
|
121
|
-
/**
|
|
122
|
-
* Contract type for llm extension implementations.
|
|
123
|
-
* Enforces exact function structure for compile-time verification.
|
|
124
|
-
*
|
|
125
|
-
* Backend implementations must provide all 6 functions:
|
|
126
|
-
* - message(text, options): Send single message
|
|
127
|
-
* - messages(messages, options): Multi-turn conversation
|
|
128
|
-
* - embed(text): Generate embedding vector
|
|
129
|
-
* - embed_batch(texts): Batch embeddings
|
|
130
|
-
* - tool_loop(prompt, options): Tool use orchestration
|
|
131
|
-
* - generate(prompt, options): Structured output extraction
|
|
132
|
-
*/
|
|
133
|
-
export type LlmExtensionContract = {
|
|
134
|
-
readonly message: RillFunction;
|
|
135
|
-
readonly messages: RillFunction;
|
|
136
|
-
readonly embed: RillFunction;
|
|
137
|
-
readonly embed_batch: RillFunction;
|
|
138
|
-
readonly tool_loop: RillFunction;
|
|
139
|
-
readonly generate: RillFunction;
|
|
140
|
-
readonly dispose?: (() => void | Promise<void>) | undefined;
|
|
141
|
-
};
|
|
142
|
-
/**
|
|
143
|
-
* Contract type for vector extension implementations.
|
|
144
|
-
* Enforces exact function structure for compile-time verification.
|
|
145
|
-
*
|
|
146
|
-
* Backend implementations must provide all 11 functions:
|
|
147
|
-
* - upsert(id, vector, metadata): Insert or update vector
|
|
148
|
-
* - upsert_batch(items): Batch insert/update
|
|
149
|
-
* - search(vector, options): Search k nearest neighbors
|
|
150
|
-
* - get(id): Fetch vector by ID
|
|
151
|
-
* - delete(id): Delete vector by ID
|
|
152
|
-
* - delete_batch(ids): Batch delete
|
|
153
|
-
* - count(): Count vectors in collection
|
|
154
|
-
* - create_collection(name, options): Create collection
|
|
155
|
-
* - delete_collection(name): Delete collection
|
|
156
|
-
* - list_collections(): List all collections
|
|
157
|
-
* - describe(): Get collection metadata
|
|
158
|
-
*/
|
|
159
|
-
export type VectorExtensionContract = {
|
|
160
|
-
readonly upsert: RillFunction;
|
|
161
|
-
readonly upsert_batch: RillFunction;
|
|
162
|
-
readonly search: RillFunction;
|
|
163
|
-
readonly get: RillFunction;
|
|
164
|
-
readonly delete: RillFunction;
|
|
165
|
-
readonly delete_batch: RillFunction;
|
|
166
|
-
readonly count: RillFunction;
|
|
167
|
-
readonly create_collection: RillFunction;
|
|
168
|
-
readonly delete_collection: RillFunction;
|
|
169
|
-
readonly list_collections: RillFunction;
|
|
170
|
-
readonly describe: RillFunction;
|
|
171
|
-
readonly dispose?: (() => void | Promise<void>) | undefined;
|
|
100
|
+
readonly read: ApplicationCallable;
|
|
101
|
+
readonly write: ApplicationCallable;
|
|
102
|
+
readonly append: ApplicationCallable;
|
|
103
|
+
readonly list: ApplicationCallable;
|
|
104
|
+
readonly find: ApplicationCallable;
|
|
105
|
+
readonly exists: ApplicationCallable;
|
|
106
|
+
readonly remove: ApplicationCallable;
|
|
107
|
+
readonly stat: ApplicationCallable;
|
|
108
|
+
readonly mkdir: ApplicationCallable;
|
|
109
|
+
readonly copy: ApplicationCallable;
|
|
110
|
+
readonly move: ApplicationCallable;
|
|
111
|
+
readonly mounts: ApplicationCallable;
|
|
172
112
|
};
|
|
173
|
-
/**
|
|
174
|
-
* Prefix all function names in an extension with a namespace.
|
|
175
|
-
*
|
|
176
|
-
* @param namespace - Alphanumeric string with underscores/hyphens (e.g., "fs", "claude_code")
|
|
177
|
-
* @param functions - Extension result with function definitions
|
|
178
|
-
* @returns New ExtensionResult with prefixed function names (namespace::functionName)
|
|
179
|
-
* @throws {RuntimeError} RUNTIME_TYPE_ERROR if namespace is invalid
|
|
180
|
-
*
|
|
181
|
-
* @example
|
|
182
|
-
* ```typescript
|
|
183
|
-
* const fs = createFsExtension();
|
|
184
|
-
* const prefixed = prefixFunctions("fs", fs);
|
|
185
|
-
* // { "fs::read": ..., "fs::write": ..., dispose: ... }
|
|
186
|
-
* ```
|
|
187
|
-
*/
|
|
188
|
-
export declare function prefixFunctions(namespace: string, functions: ExtensionResult): ExtensionResult;
|
|
189
|
-
/**
|
|
190
|
-
* Separate dispose from functions for safe createRuntimeContext usage.
|
|
191
|
-
* Wraps prefixFunctions and returns separated structure.
|
|
192
|
-
*
|
|
193
|
-
* @param namespace - String matching /^[a-zA-Z0-9_-]+$/
|
|
194
|
-
* @param extension - Output from extension factory
|
|
195
|
-
* @returns Separated functions and dispose handler
|
|
196
|
-
* @throws {Error} If namespace is empty
|
|
197
|
-
* @throws {Error} If namespace has invalid format
|
|
198
|
-
* @throws {TypeError} If extension is null or undefined
|
|
199
|
-
*
|
|
200
|
-
* @example
|
|
201
|
-
* ```typescript
|
|
202
|
-
* const { functions, dispose } = hoistExtension('db', dbExtension);
|
|
203
|
-
* const ctx = createRuntimeContext({ functions });
|
|
204
|
-
* ```
|
|
205
|
-
*/
|
|
206
|
-
export declare function hoistExtension(namespace: string, extension: ExtensionResult): HoistedExtension;
|
|
207
113
|
/**
|
|
208
114
|
* Emit an extension event with auto-generated timestamp.
|
|
209
115
|
* Adds ISO timestamp if event.timestamp is undefined, then calls onLogEvent callback.
|
|
@@ -227,4 +133,3 @@ export declare function emitExtensionEvent(ctx: RuntimeContextLike, event: Omit<
|
|
|
227
133
|
timestamp?: string | undefined;
|
|
228
134
|
}): void;
|
|
229
135
|
export {};
|
|
230
|
-
//# sourceMappingURL=extensions.d.ts.map
|