@superpanel-sdk/runtime 0.2.3 → 0.7.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 +30 -10
- package/dist/builder/codegen/emit.d.ts +25 -12
- package/dist/builder/codegen/emit.js +339 -78
- package/dist/builder/codegen/generate.d.ts +21 -2
- package/dist/builder/codegen/generate.js +147 -34
- package/dist/builder/company-import-graph.d.ts +2 -0
- package/dist/builder/company-import-graph.js +40 -8
- package/dist/builder/company-imports.d.ts +29 -0
- package/dist/builder/company-imports.js +122 -0
- package/dist/builder/compile/compile-sequence.d.ts +61 -8
- package/dist/builder/compile/compile-sequence.js +334 -80
- package/dist/builder/compile/function-code.d.ts +19 -3
- package/dist/builder/compile/function-code.js +123 -45
- package/dist/builder/compile/registry.d.ts +7 -3
- package/dist/builder/compile/registry.js +30 -27
- package/dist/builder/errors.d.ts +9 -0
- package/dist/builder/errors.js +17 -0
- package/dist/builder/function-params.d.ts +10 -0
- package/dist/builder/function-params.js +203 -0
- package/dist/builder/load.d.ts +70 -10
- package/dist/builder/load.js +258 -67
- package/dist/builder/paths.d.ts +9 -1
- package/dist/builder/paths.js +32 -2
- package/dist/builder/schedules.d.ts +25 -0
- package/dist/builder/schedules.js +101 -0
- package/dist/builder/slot-schema-validation.d.ts +4 -0
- package/dist/builder/slot-schema-validation.js +10 -0
- package/dist/builder/typecheck.d.ts +8 -0
- package/dist/builder/typecheck.js +102 -0
- package/dist/builder/types.d.ts +127 -19
- package/dist/builder/types.js +21 -1
- package/dist/cli/auth/auth.d.ts +37 -0
- package/dist/cli/auth/auth.js +211 -0
- package/dist/cli/auth/backend-url.d.ts +5 -0
- package/dist/cli/auth/backend-url.js +25 -0
- package/dist/cli/auth/clipboard.d.ts +9 -0
- package/dist/cli/auth/clipboard.js +38 -0
- package/dist/cli/auth/http.d.ts +20 -0
- package/dist/cli/auth/http.js +27 -0
- package/dist/cli/auth/index.d.ts +10 -0
- package/dist/cli/auth/index.js +27 -0
- package/dist/cli/auth/progress.d.ts +12 -0
- package/dist/cli/auth/progress.js +15 -0
- package/dist/cli/auth/serve-login.d.ts +8 -0
- package/dist/cli/auth/serve-login.js +24 -0
- package/dist/cli/calls/index.d.ts +177 -0
- package/dist/cli/calls/index.js +96 -0
- package/dist/cli/compile/index.js +3 -0
- package/dist/cli/config.d.ts +10 -0
- package/dist/cli/config.js +52 -0
- package/dist/cli/debug/index.d.ts +31 -0
- package/dist/cli/debug/index.js +119 -0
- package/dist/cli/exec/index.d.ts +39 -0
- package/dist/cli/exec/index.js +138 -0
- package/dist/cli/exec/session.d.ts +48 -0
- package/dist/cli/exec/session.js +82 -0
- package/dist/cli/exec/trace.d.ts +18 -0
- package/dist/cli/exec/trace.js +52 -0
- package/dist/cli/index.js +112 -9
- package/dist/cli/logs/index.d.ts +47 -0
- package/dist/cli/logs/index.js +113 -0
- package/dist/cli/mobile/index.d.ts +12 -0
- package/dist/cli/mobile/index.js +405 -0
- package/dist/cli/serve/index.d.ts +109 -3
- package/dist/cli/serve/index.js +506 -118
- package/dist/cli/turns/index.d.ts +105 -0
- package/dist/cli/turns/index.js +128 -0
- package/dist/cli/turns/run.d.ts +13 -0
- package/dist/cli/turns/run.js +57 -0
- package/dist/cli/turns/shadow.d.ts +112 -0
- package/dist/cli/turns/shadow.js +54 -0
- package/dist/cli/type-gen/index.js +9 -9
- package/dist/compiler.d.ts +7 -0
- package/dist/compiler.js +7 -0
- package/dist/compute-host/compute-host.d.ts +14 -23
- package/dist/compute-host/compute-host.js +18 -30
- package/dist/compute-host/index.d.ts +2 -4
- package/dist/compute-host/index.js +1 -2
- package/dist/compute-host/source-compute-host.d.ts +10 -10
- package/dist/compute-host/source-compute-host.js +33 -40
- package/dist/core/case-orchestrator/contact-hours.d.ts +70 -0
- package/dist/core/case-orchestrator/contact-hours.js +127 -0
- package/dist/core/case-orchestrator/index.d.ts +3 -0
- package/dist/core/case-orchestrator/index.js +3 -0
- package/dist/core/case-orchestrator/render.d.ts +75 -0
- package/dist/core/case-orchestrator/render.js +244 -0
- package/dist/core/case-orchestrator/time.d.ts +11 -0
- package/dist/core/case-orchestrator/time.js +29 -0
- package/dist/core/case-orchestrator/types.d.ts +708 -0
- package/dist/core/case-orchestrator/types.js +42 -0
- package/dist/core/context/call.d.ts +291 -0
- package/dist/core/context/call.js +94 -0
- package/dist/core/context/channels.d.ts +60 -0
- package/dist/core/context/channels.js +35 -0
- package/dist/core/context/contact.d.ts +96 -6
- package/dist/core/context/contact.js +48 -2
- package/dist/core/context/email-message.d.ts +198 -0
- package/dist/core/context/email-message.js +86 -0
- package/dist/core/context/email.d.ts +109 -0
- package/dist/core/context/email.js +90 -0
- package/dist/core/context/exchanges.d.ts +167 -0
- package/dist/core/context/exchanges.js +81 -0
- package/dist/core/context/instances.d.ts +307 -0
- package/dist/core/context/instances.js +137 -0
- package/dist/core/context/kv.d.ts +113 -0
- package/dist/core/context/kv.js +60 -0
- package/dist/core/context/platform-registry.d.ts +544 -4
- package/dist/core/context/platform-registry.js +14 -2
- package/dist/core/context/platform.d.ts +2 -1
- package/dist/core/context/sms.d.ts +177 -0
- package/dist/core/context/sms.js +77 -0
- package/dist/core/context/types.d.ts +79 -48
- package/dist/core/context/types.js +1 -7
- package/dist/core/conversation/index.d.ts +85 -0
- package/dist/core/conversation/index.js +133 -0
- package/dist/core/functions/errors.d.ts +74 -0
- package/dist/core/functions/errors.js +26 -0
- package/dist/core/functions/events.d.ts +192 -0
- package/dist/core/functions/events.js +23 -0
- package/dist/core/functions/schedules.d.ts +50 -0
- package/dist/core/functions/schedules.js +20 -0
- package/dist/core/functions/types.d.ts +29 -73
- package/dist/core/functions/types.js +1 -4
- package/dist/core/office-hours/index.d.ts +39 -0
- package/dist/core/office-hours/index.js +187 -0
- package/dist/core/page/define.d.ts +904 -0
- package/dist/core/page/define.js +518 -0
- package/dist/core/page/envelope.d.ts +55 -0
- package/dist/core/page/envelope.js +4 -0
- package/dist/core/page/fns.d.ts +448 -0
- package/dist/core/page/fns.js +539 -0
- package/dist/core/page/memory-reader.d.ts +27 -0
- package/dist/core/page/memory-reader.js +299 -0
- package/dist/core/page/ops.d.ts +58 -0
- package/dist/core/page/ops.js +220 -0
- package/dist/core/page/page-host.d.ts +20 -0
- package/dist/core/page/page-host.js +57 -0
- package/dist/core/page/records-query.d.ts +234 -0
- package/dist/core/page/records-query.js +780 -0
- package/dist/core/page/render.d.ts +295 -0
- package/dist/core/page/render.js +1060 -0
- package/dist/core/page/sandbox.d.ts +85 -0
- package/dist/core/page/sandbox.js +357 -0
- package/dist/core/page/time-format.d.ts +46 -0
- package/dist/core/page/time-format.js +125 -0
- package/dist/core/page/timeline.d.ts +40 -0
- package/dist/core/page/timeline.js +2 -0
- package/dist/core/page/typed.d.ts +648 -0
- package/dist/core/page/typed.js +2 -0
- package/dist/core/page/workspace.d.ts +57 -0
- package/dist/core/page/workspace.js +266 -0
- package/dist/core/party/index.d.ts +3 -0
- package/dist/core/party/index.js +3 -0
- package/dist/core/party/schema.d.ts +208 -0
- package/dist/core/party/schema.js +113 -0
- package/dist/core/party/types.d.ts +35 -0
- package/dist/core/party/types.js +15 -0
- package/dist/core/sequence/define.d.ts +56 -0
- package/dist/core/sequence/define.js +10 -0
- package/dist/core/sequence/index.d.ts +63 -0
- package/dist/core/sequence/index.js +231 -0
- package/dist/core/slot/binding.d.ts +40 -0
- package/dist/core/slot/binding.js +2 -0
- package/dist/core/slot/company-metadata.d.ts +102 -0
- package/dist/core/slot/company-metadata.js +536 -0
- package/dist/core/slot/compile-schema.d.ts +19 -13
- package/dist/core/slot/compile-schema.js +51 -248
- package/dist/core/slot/contact-timezone.d.ts +110 -0
- package/dist/core/slot/contact-timezone.js +186 -0
- package/dist/core/slot/field.d.ts +2 -25
- package/dist/core/slot/field.js +0 -71
- package/dist/core/slot/id-ref.d.ts +17 -2
- package/dist/core/slot/id-ref.js +16 -8
- package/dist/core/slot/index.d.ts +12 -13
- package/dist/core/slot/index.js +11 -12
- package/dist/core/slot/naming.d.ts +15 -0
- package/dist/core/slot/naming.js +96 -0
- package/dist/core/slot/platform-fields.d.ts +119 -0
- package/dist/core/slot/platform-fields.js +121 -0
- package/dist/core/slot/ref.d.ts +16 -0
- package/dist/core/slot/ref.js +14 -0
- package/dist/core/slot/row.d.ts +2 -9
- package/dist/core/slot/row.js +13 -23
- package/dist/core/slot/schema-compat.d.ts +17 -0
- package/dist/core/slot/schema-compat.js +103 -0
- package/dist/core/slot/schema.d.ts +353 -76
- package/dist/core/slot/schema.js +163 -10
- package/dist/core/slot/types.d.ts +30 -103
- package/dist/core/slot/value.d.ts +28 -3
- package/dist/core/slot/value.js +93 -57
- package/dist/dev-overlay/protocol.d.ts +74 -8
- package/dist/fn-context/build-context.d.ts +3 -1
- package/dist/fn-context/build-context.js +26 -10
- package/dist/fn-context/fake/empty-api.js +9 -28
- package/dist/fn-context/fake/index.d.ts +13 -4
- package/dist/fn-context/fake/index.js +29 -2
- package/dist/fn-context/fn-params.d.ts +3 -0
- package/dist/fn-context/fn-params.js +10 -0
- package/dist/fn-context/index.d.ts +5 -5
- package/dist/fn-context/index.js +4 -4
- package/dist/fn-context/log.js +2 -2
- package/dist/fn-context/make-ctx.d.ts +11 -0
- package/dist/fn-context/make-ctx.js +20 -9
- package/dist/fn-context/rpc/case-orchestrator-tools.d.ts +32 -0
- package/dist/fn-context/rpc/case-orchestrator-tools.js +12 -0
- package/dist/fn-context/rpc/errors.d.ts +13 -0
- package/dist/fn-context/rpc/errors.js +22 -0
- package/dist/fn-context/rpc/index.d.ts +4 -2
- package/dist/fn-context/rpc/index.js +4 -2
- package/dist/fn-context/rpc/integration/index.d.ts +15 -5
- package/dist/fn-context/rpc/integration/index.js +1 -1
- package/dist/fn-context/rpc/integration/list-surfaces.d.ts +21 -0
- package/dist/fn-context/rpc/integration/{list-bindings.js → list-surfaces.js} +4 -4
- package/dist/fn-context/rpc/log.d.ts +11 -1
- package/dist/fn-context/rpc/platform.d.ts +13 -3
- package/dist/fn-context/rpc/platform.js +1 -1
- package/dist/fn-context/rpc/records.d.ts +85 -0
- package/dist/fn-context/rpc/records.js +24 -0
- package/dist/fn-context/rpc/trpc-client.d.ts +44 -2
- package/dist/fn-context/rpc/trpc-client.js +222 -12
- package/dist/fn-context/rpc/trpc-init.d.ts +21 -3
- package/dist/fn-context/rpc/trpc-init.js +10 -4
- package/dist/fn-context/rpc/trpc-router-factory.d.ts +111 -7
- package/dist/fn-context/rpc/trpc-router-factory.js +2 -0
- package/dist/fn-context/run-scope.d.ts +4 -0
- package/dist/fn-context/run-scope.js +9 -0
- package/dist/fn-context/types.d.ts +52 -5
- package/dist/index.d.ts +36 -46
- package/dist/index.js +30 -33
- package/dist/logger.d.ts +11 -0
- package/dist/logger.js +49 -0
- package/dist/platform.d.ts +75 -0
- package/dist/platform.js +57 -0
- package/dist/testing-compile-child.d.ts +2 -0
- package/dist/testing-compile-child.js +20 -0
- package/dist/testing.d.ts +368 -0
- package/dist/testing.js +439 -0
- package/dist/voice-service/actions.d.ts +50 -6
- package/dist/voice-service/index.d.ts +2 -0
- package/dist/voice-service/index.js +2 -0
- package/dist/voice-service/protocol.d.ts +604 -0
- package/dist/voice-service/protocol.js +67 -0
- package/dist/voice-service/types.d.ts +55 -8
- package/dist/worker.d.ts +11 -0
- package/dist/worker.js +11 -0
- package/package.json +38 -15
- package/dist/builder/compile/compile-agenda.d.ts +0 -15
- package/dist/builder/compile/compile-agenda.js +0 -64
- package/dist/builder/merge.d.ts +0 -4
- package/dist/builder/merge.js +0 -19
- package/dist/compute-host/read-only-cache.d.ts +0 -20
- package/dist/compute-host/read-only-cache.js +0 -61
- package/dist/core/context/db.d.ts +0 -69
- package/dist/core/context/db.js +0 -44
- package/dist/core/context/docusign.d.ts +0 -134
- package/dist/core/context/docusign.js +0 -108
- package/dist/core/context/filevine.d.ts +0 -323
- package/dist/core/context/filevine.js +0 -254
- package/dist/core/context/http.d.ts +0 -9
- package/dist/core/context/http.js +0 -4
- package/dist/core/context/hubspot.d.ts +0 -250
- package/dist/core/context/hubspot.js +0 -191
- package/dist/core/context/twilio.d.ts +0 -50
- package/dist/core/context/twilio.js +0 -42
- package/dist/core/functions/define/case-context.d.ts +0 -14
- package/dist/core/functions/define/case-context.js +0 -15
- package/dist/core/functions/define/compute.d.ts +0 -7
- package/dist/core/functions/define/compute.js +0 -17
- package/dist/core/functions/define/custom.d.ts +0 -4
- package/dist/core/functions/define/custom.js +0 -8
- package/dist/core/functions/define/system.d.ts +0 -7
- package/dist/core/functions/define/system.js +0 -12
- package/dist/core/functions/func-ref.d.ts +0 -16
- package/dist/core/functions/func-ref.js +0 -20
- package/dist/core/slot/deps.d.ts +0 -15
- package/dist/core/slot/deps.js +0 -88
- package/dist/core/slot/derived.d.ts +0 -32
- package/dist/core/slot/derived.js +0 -115
- package/dist/core/slot/platform-session-fields.d.ts +0 -38
- package/dist/core/slot/platform-session-fields.js +0 -48
- package/dist/core/slot/sf-schema.d.ts +0 -23
- package/dist/core/slot/sf-schema.js +0 -125
- package/dist/core/slot/sf-validate.d.ts +0 -14
- package/dist/core/slot/sf-validate.js +0 -132
- package/dist/core/slot/snapshot.d.ts +0 -18
- package/dist/core/slot/snapshot.js +0 -138
- package/dist/core/slot/write.d.ts +0 -48
- package/dist/core/slot/write.js +0 -426
- package/dist/core/stage/builders.d.ts +0 -54
- package/dist/core/stage/builders.js +0 -31
- package/dist/core/stage/condition.d.ts +0 -17
- package/dist/core/stage/condition.js +0 -198
- package/dist/core/stage/drive.d.ts +0 -43
- package/dist/core/stage/drive.js +0 -78
- package/dist/core/stage/finish-when.d.ts +0 -20
- package/dist/core/stage/finish-when.js +0 -82
- package/dist/core/stage/flatten.d.ts +0 -27
- package/dist/core/stage/flatten.js +0 -466
- package/dist/core/stage/index.d.ts +0 -15
- package/dist/core/stage/index.js +0 -13
- package/dist/core/stage/interrupts.d.ts +0 -28
- package/dist/core/stage/interrupts.js +0 -120
- package/dist/core/stage/ivr-fields.d.ts +0 -9
- package/dist/core/stage/ivr-fields.js +0 -75
- package/dist/core/stage/simulate.d.ts +0 -24
- package/dist/core/stage/simulate.js +0 -33
- package/dist/core/stage/transfer-fields.d.ts +0 -19
- package/dist/core/stage/transfer-fields.js +0 -129
- package/dist/core/stage/transfer-spec.d.ts +0 -48
- package/dist/core/stage/transfer-spec.js +0 -113
- package/dist/core/stage/types.d.ts +0 -208
- package/dist/core/stage/types.js +0 -2
- package/dist/core/stage/validate.d.ts +0 -11
- package/dist/core/stage/validate.js +0 -330
- package/dist/core/stage/walk.d.ts +0 -39
- package/dist/core/stage/walk.js +0 -119
- package/dist/fn-context/rpc/integration/list-bindings.d.ts +0 -21
- package/dist/fn-context/system-args.d.ts +0 -6
- package/dist/fn-context/system-args.js +0 -14
|
@@ -0,0 +1,448 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pages written with functions (76): what `context.page.ts` is written with. Every node and every action
|
|
3
|
+
* is a platform function returning its own type: `page()`, `block()`, `list()`, `field()`, `text()`,
|
|
4
|
+
* `data()`, `button()`, `doNow()`, `toolbox()`; actions `run()`, `createRow()`, `warmTransfer()`, …
|
|
5
|
+
* A node carries a mark no JSON can carry (31 §8), so data from outside never becomes a field or a
|
|
6
|
+
* button. The page module turns the tree into the envelope (`toFnPageResult`), the one thing the
|
|
7
|
+
* platform reads (`render.ts`): what the AI reads of the page does not change (76 §2.20).
|
|
8
|
+
*
|
|
9
|
+
* The types here are the generic ones; `typed.ts` binds `page`'s extraction, `field`'s slot, `createRow`,
|
|
10
|
+
* `deleteRow` and `run` to one sequence's tables, functions (`fn`) and page actions (`act`) (`__gen/index.ts`).
|
|
11
|
+
*
|
|
12
|
+
* Runs in the page's QuickJS sandbox like the rest of the page module: no imports at runtime but the
|
|
13
|
+
* page module's own.
|
|
14
|
+
*/
|
|
15
|
+
import { type ChooseParam, type FieldCell, type RefFieldCell, type PageAction, type PageRow, type RefOption, type Slot, type SlotRef } from './define.js';
|
|
16
|
+
import type { Envelope } from './envelope.js';
|
|
17
|
+
import type { Spoken } from '../conversation/index.js';
|
|
18
|
+
/** The mark of a node: `Symbol.for`, the same in every copy of the page module a bundle may hold. */
|
|
19
|
+
export declare const NODE: unique symbol;
|
|
20
|
+
/** The mark of an action (what a button or `doNow` does). */
|
|
21
|
+
export declare const ACTION: unique symbol;
|
|
22
|
+
/** The mark of a handle `run()` takes: a company function (`fn.x`) or a page action (`act.x`). */
|
|
23
|
+
export declare const HANDLE: unique symbol;
|
|
24
|
+
/** The mark of a platform tool (`pressKeypad()`, `convertTime()`). */
|
|
25
|
+
export declare const TOOL: unique symbol;
|
|
26
|
+
declare const KEYED: unique symbol;
|
|
27
|
+
declare const READY: unique symbol;
|
|
28
|
+
declare const NOT_BUTTON: unique symbol;
|
|
29
|
+
declare const ARGS: unique symbol;
|
|
30
|
+
/** What `doNow()` asks of an action's run key (76 §2.14). */
|
|
31
|
+
export type RunKeyGiven = 'runKey given';
|
|
32
|
+
export type RunKeyMissing = 'no runKey';
|
|
33
|
+
/** Whether `K`, the type of an action's `runKey`, is given. */
|
|
34
|
+
export type KeyedOf<K> = [K] extends [string] ? RunKeyGiven : RunKeyMissing;
|
|
35
|
+
/** What `doNow()` asks of a `run()`'s parameters (76 §2.15). */
|
|
36
|
+
export type AllPrefilled = 'every required parameter prefilled';
|
|
37
|
+
export type LeftForAi = 'some left for the AI';
|
|
38
|
+
export interface PageNode {
|
|
39
|
+
readonly [NODE]: 'page';
|
|
40
|
+
}
|
|
41
|
+
export interface BlockNode {
|
|
42
|
+
readonly [NODE]: 'block';
|
|
43
|
+
}
|
|
44
|
+
export interface ListNode {
|
|
45
|
+
readonly [NODE]: 'list';
|
|
46
|
+
}
|
|
47
|
+
export interface FieldNode {
|
|
48
|
+
readonly [NODE]: 'field';
|
|
49
|
+
}
|
|
50
|
+
export interface TextNode {
|
|
51
|
+
readonly [NODE]: 'text';
|
|
52
|
+
}
|
|
53
|
+
export interface DataNode {
|
|
54
|
+
readonly [NODE]: 'data';
|
|
55
|
+
}
|
|
56
|
+
export interface ButtonNode {
|
|
57
|
+
readonly [NODE]: 'button';
|
|
58
|
+
}
|
|
59
|
+
export interface ToolboxNode {
|
|
60
|
+
readonly [NODE]: 'toolbox';
|
|
61
|
+
}
|
|
62
|
+
export interface DoNode {
|
|
63
|
+
readonly [NODE]: 'do';
|
|
64
|
+
}
|
|
65
|
+
/** Left out of a block or a list: `verify: verified ? undefined : button(…)`, `x && field(…)`. */
|
|
66
|
+
export type Skip = undefined | null | false;
|
|
67
|
+
/**
|
|
68
|
+
* What a block holds: nodes only. A text is `text(…)`, data `data(…)`; a value that may be empty is
|
|
69
|
+
* `x ? text(x) : undefined` (`x && text(x)` may be `''` or `0`, not a node).
|
|
70
|
+
*/
|
|
71
|
+
export type PageItem = BlockNode | ListNode | FieldNode | TextNode | DataNode | ButtonNode | ToolboxNode;
|
|
72
|
+
/** A block's or a page's content: its items by name. A button's or a toolbox's name is the code's only (76 §2.3). */
|
|
73
|
+
export type PageContent = {
|
|
74
|
+
readonly [name: string]: PageItem | Skip;
|
|
75
|
+
};
|
|
76
|
+
/** What a list holds: one kind of node (76 §2.10). */
|
|
77
|
+
export type ListItem = BlockNode | FieldNode | TextNode | ButtonNode;
|
|
78
|
+
type UnionToIntersection<U> = (U extends unknown ? (x: U) => void : never) extends (x: infer I) => void ? I : never;
|
|
79
|
+
/** A list of one kind of node, or the sentence tsc says (76 §2.10). */
|
|
80
|
+
export type OneKind<I> = [I] extends [UnionToIntersection<I>] ? unknown : {
|
|
81
|
+
'list items are all one kind: all block(), all field(), all text() or all button()': true;
|
|
82
|
+
};
|
|
83
|
+
/** Whether a page node or an action is anywhere in `T` (at most 8 levels; data of unknown shape is data). */
|
|
84
|
+
export type HoldsNode<T, Depth extends unknown[] = []> = Depth['length'] extends 8 ? false : T extends {
|
|
85
|
+
readonly [NODE]: string;
|
|
86
|
+
} | {
|
|
87
|
+
readonly [ACTION]: string;
|
|
88
|
+
} ? true : T extends readonly (infer E)[] ? HoldsNode<E, [...Depth, 0]> : T extends (...args: never[]) => unknown ? false : T extends object ? true extends {
|
|
89
|
+
[K in keyof T]-?: HoldsNode<T[K], [...Depth, 0]>;
|
|
90
|
+
}[keyof T] ? true : false : false;
|
|
91
|
+
/** Data with no node in it, or the sentence tsc says (76 §2.8). */
|
|
92
|
+
export type NoNodes<T> = true extends HoldsNode<T> ? {
|
|
93
|
+
'data() holds data only: put page nodes in block()': true;
|
|
94
|
+
} : unknown;
|
|
95
|
+
/** The words of a block or a list (`<block title description>`). */
|
|
96
|
+
export type BlockSettings = {
|
|
97
|
+
title?: string;
|
|
98
|
+
description?: string;
|
|
99
|
+
};
|
|
100
|
+
/** The page's settings (31 §9): `guide`, `extraction`, `voice`, `title`, `description`. */
|
|
101
|
+
export type PageSettings<Extraction = Record<string, string>> = {
|
|
102
|
+
title?: string;
|
|
103
|
+
description?: string;
|
|
104
|
+
/** What to do now and how (24 §2.1). */
|
|
105
|
+
guide?: string;
|
|
106
|
+
/** How to fill a field on this page, by `table.field` (26 §15.3). */
|
|
107
|
+
extraction?: Extraction;
|
|
108
|
+
/** The voice to speak with from the next line (2026-11-03 voice rule). */
|
|
109
|
+
voice?: {
|
|
110
|
+
name: string;
|
|
111
|
+
[setting: string]: unknown;
|
|
112
|
+
};
|
|
113
|
+
};
|
|
114
|
+
/** Handles `run()` takes: a company function by name (`fn.x`), a page action of `actions.ts` (`act.x`). */
|
|
115
|
+
export interface FunctionHandle<N extends string = string, A = unknown> {
|
|
116
|
+
readonly [HANDLE]: 'function';
|
|
117
|
+
readonly name: N;
|
|
118
|
+
readonly [ARGS]?: (args: A) => void;
|
|
119
|
+
}
|
|
120
|
+
export interface PageActionHandle<N extends string = string, A = unknown> {
|
|
121
|
+
readonly [HANDLE]: 'action';
|
|
122
|
+
readonly name: N;
|
|
123
|
+
readonly [ARGS]?: (args: A) => void;
|
|
124
|
+
}
|
|
125
|
+
export type RunHandle<A = unknown> = FunctionHandle<string, A> | PageActionHandle<string, A>;
|
|
126
|
+
/** The `args` a handle's function takes. */
|
|
127
|
+
export type HandleArgs<H> = H extends {
|
|
128
|
+
readonly [ARGS]?: (args: infer A) => void;
|
|
129
|
+
} ? A : never;
|
|
130
|
+
/** An action: what a button or `doNow()` does. `V` its verb; the marks say where it may go (76 §2.6, §2.14, §2.15). */
|
|
131
|
+
export interface Action<V extends string = string, K = RunKeyGiven | RunKeyMissing, R = AllPrefilled | LeftForAi> {
|
|
132
|
+
readonly [ACTION]: V;
|
|
133
|
+
readonly [KEYED]: K;
|
|
134
|
+
readonly [READY]: R;
|
|
135
|
+
}
|
|
136
|
+
export interface RunAction<K = RunKeyGiven | RunKeyMissing, R = AllPrefilled | LeftForAi> extends Action<'run', K, R> {
|
|
137
|
+
}
|
|
138
|
+
export interface TransferVerbAction<K = RunKeyGiven | RunKeyMissing> extends Action<'transfer', K, AllPrefilled> {
|
|
139
|
+
}
|
|
140
|
+
export interface AnnounceVerbAction extends Action<'announce', RunKeyGiven, AllPrefilled> {
|
|
141
|
+
readonly [NOT_BUTTON]: 'announce() is only for doNow(): the AI never presses it';
|
|
142
|
+
}
|
|
143
|
+
/** A follow-up is a button only: the AI books it with the customer. Its run-key mark says so to `doNow()`. */
|
|
144
|
+
export interface FollowUpVerbAction<V extends string = 'scheduleFollowUp' | 'cancelFollowUp'> extends Action<V, 'a button only: the AI books it with the customer', AllPrefilled> {
|
|
145
|
+
}
|
|
146
|
+
/** What a button may do: any action but `announce()`. */
|
|
147
|
+
export type ButtonAction = {
|
|
148
|
+
readonly [ACTION]: string;
|
|
149
|
+
readonly [NOT_BUTTON]?: undefined;
|
|
150
|
+
};
|
|
151
|
+
/**
|
|
152
|
+
* What `doNow()` may do: an action with its run key (the name `tried(ctx.runs, …)` checks, 76 §2.14) and
|
|
153
|
+
* every required parameter prefilled (nobody fills the rest); not a follow-up.
|
|
154
|
+
*/
|
|
155
|
+
export type DoAction = {
|
|
156
|
+
readonly [ACTION]: string;
|
|
157
|
+
readonly [KEYED]: RunKeyGiven;
|
|
158
|
+
readonly [READY]: AllPrefilled;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* A button's words (31 §5): `run` says what it is and when to press it; a transfer who it goes to; the rest
|
|
162
|
+
* have the platform's. An action that may be one of several (`flag ? warmTransfer(…) : end()`) needs the
|
|
163
|
+
* words of the strictest it may be: whichever it turns out to be, its words are there.
|
|
164
|
+
*/
|
|
165
|
+
export type ButtonWords<X> = [Extract<X, {
|
|
166
|
+
readonly [ACTION]: 'run';
|
|
167
|
+
}>] extends [never] ? [Extract<X, {
|
|
168
|
+
readonly [ACTION]: 'transfer';
|
|
169
|
+
}>] extends [never] ? {
|
|
170
|
+
title?: string;
|
|
171
|
+
does?: string;
|
|
172
|
+
} : {
|
|
173
|
+
title: string;
|
|
174
|
+
does?: string;
|
|
175
|
+
} : {
|
|
176
|
+
title: string; /** When to press it. */
|
|
177
|
+
does: string;
|
|
178
|
+
};
|
|
179
|
+
/** What the page fixed of an action's parameters (35 §2): an optional one may be `null`. */
|
|
180
|
+
export type PrefillOf<A> = {
|
|
181
|
+
[K in keyof A]?: A[K] | (undefined extends A[K] ? null : never);
|
|
182
|
+
};
|
|
183
|
+
/** The required parameters of `A`. */
|
|
184
|
+
export type RequiredKeys<A> = {
|
|
185
|
+
[K in keyof A]-?: undefined extends A[K] ? never : K;
|
|
186
|
+
}[keyof A];
|
|
187
|
+
/** Every required parameter prefilled, none of them null. */
|
|
188
|
+
export type FullPrefill<A> = {
|
|
189
|
+
[K in RequiredKeys<A>]: A[K];
|
|
190
|
+
} & PrefillOf<A>;
|
|
191
|
+
/** A tool of the platform's (76 §2.18): placed in `toolbox()`. */
|
|
192
|
+
export interface Tool<N extends string = string> {
|
|
193
|
+
readonly [TOOL]: N;
|
|
194
|
+
}
|
|
195
|
+
type Words = {
|
|
196
|
+
label?: string;
|
|
197
|
+
description?: string;
|
|
198
|
+
};
|
|
199
|
+
type Built = {
|
|
200
|
+
action: PageAction;
|
|
201
|
+
key?: string;
|
|
202
|
+
};
|
|
203
|
+
type RawAction = {
|
|
204
|
+
readonly [ACTION]: string;
|
|
205
|
+
/** The action as rendered, with the button's words. */
|
|
206
|
+
readonly build: (words: Words, mode: 'button' | 'do') => Built;
|
|
207
|
+
readonly runKey?: string;
|
|
208
|
+
};
|
|
209
|
+
type RawNode = {
|
|
210
|
+
readonly [NODE]: 'page';
|
|
211
|
+
settings: Record<string, unknown>;
|
|
212
|
+
content: unknown;
|
|
213
|
+
} | {
|
|
214
|
+
readonly [NODE]: 'block';
|
|
215
|
+
settings: Record<string, unknown>;
|
|
216
|
+
content: unknown;
|
|
217
|
+
} | {
|
|
218
|
+
readonly [NODE]: 'list';
|
|
219
|
+
settings: Record<string, unknown>;
|
|
220
|
+
items: unknown;
|
|
221
|
+
} | {
|
|
222
|
+
readonly [NODE]: 'field';
|
|
223
|
+
make: () => FieldCell | RefFieldCell;
|
|
224
|
+
} | {
|
|
225
|
+
readonly [NODE]: 'text';
|
|
226
|
+
text: string;
|
|
227
|
+
} | {
|
|
228
|
+
readonly [NODE]: 'data';
|
|
229
|
+
value: unknown;
|
|
230
|
+
} | {
|
|
231
|
+
readonly [NODE]: 'button';
|
|
232
|
+
action: RawAction;
|
|
233
|
+
words: Words;
|
|
234
|
+
} | {
|
|
235
|
+
readonly [NODE]: 'toolbox';
|
|
236
|
+
tools: string[];
|
|
237
|
+
} | {
|
|
238
|
+
readonly [NODE]: 'do';
|
|
239
|
+
action: RawAction;
|
|
240
|
+
wait?: boolean;
|
|
241
|
+
};
|
|
242
|
+
/** Whether `value` is a node a platform function made. */
|
|
243
|
+
export declare function isNode(value: unknown): value is RawNode;
|
|
244
|
+
/** The page (76 §2.7): settings, then content. What a page function returns, unless it returns `doNow()`. */
|
|
245
|
+
export declare function page(settings: PageSettings, content: PageContent): PageNode;
|
|
246
|
+
/** A block (76 §2.7): settings (`{}` for none), then its content by name. */
|
|
247
|
+
export declare function block(settings: BlockSettings, content: PageContent): BlockNode;
|
|
248
|
+
/** A list (76 §2.10): settings, then items, all one kind of node (`rows.map((r) => block({}, { … }))`). */
|
|
249
|
+
export declare function list<I extends ListItem>(settings: BlockSettings, items: readonly (I | Skip)[] & OneKind<I>): ListNode;
|
|
250
|
+
/** A field the AI may write, or read only (`readOnly`). A ref field is `refField()`. */
|
|
251
|
+
export declare function field(slot: Slot, options?: {
|
|
252
|
+
readOnly?: boolean;
|
|
253
|
+
expand?: boolean;
|
|
254
|
+
}): FieldNode;
|
|
255
|
+
/** A ref field: writable, the rows it may be set to (`options`); read-only, who its value is (`label`). */
|
|
256
|
+
export declare function refField(slot: Slot, options: {
|
|
257
|
+
options: readonly RefOption[] | ChooseParam;
|
|
258
|
+
readOnly?: false;
|
|
259
|
+
} | {
|
|
260
|
+
readOnly: true;
|
|
261
|
+
label?: string;
|
|
262
|
+
}): FieldNode;
|
|
263
|
+
/** One text, read only. A value that may be empty: `x ? text(x) : undefined`. */
|
|
264
|
+
export declare function text(value: string | number): TextNode;
|
|
265
|
+
/** Data shown as it is, whatever keys it has (`$action` too): never a field or a button (31 §4). */
|
|
266
|
+
export declare function data<T>(value: T & NoNodes<T>): DataNode;
|
|
267
|
+
/** What the AI can press (31 §5): its words, and what it does (`action`). */
|
|
268
|
+
export declare function button<X extends ButtonAction>(options: {
|
|
269
|
+
action: X;
|
|
270
|
+
} & ButtonWords<X>): ButtonNode;
|
|
271
|
+
/**
|
|
272
|
+
* What the page does now (31 §6), instead of a page: the AI neither sees nor presses it. The action has
|
|
273
|
+
* its run key, the name `tried(ctx.runs, …)` checks (76 §2.14); `wait: false` only for `run()`: an action
|
|
274
|
+
* that may be one of several (`flag ? run(…) : end()`) only when every one is a `run()`.
|
|
275
|
+
*/
|
|
276
|
+
export declare function doNow<X extends DoAction>(action: X, options?: [X] extends [{
|
|
277
|
+
readonly [ACTION]: 'run';
|
|
278
|
+
}] ? {
|
|
279
|
+
wait?: boolean;
|
|
280
|
+
} : {
|
|
281
|
+
wait?: never;
|
|
282
|
+
}): DoNode;
|
|
283
|
+
/** The platform's tools the AI may use on this page (76 §2.18): one toolbox a page, each tool once. */
|
|
284
|
+
export declare function toolbox(tools: readonly Tool[]): ToolboxNode;
|
|
285
|
+
/** Press keys on the other side's automated phone menu (76 §2.18): a call only. */
|
|
286
|
+
export declare function pressKeypad(): Tool<'pressKeypad'>;
|
|
287
|
+
/** Convert between a local time in a time zone and an instant, UTC (76 §2.18, §2.19). */
|
|
288
|
+
export declare function convertTime(): Tool<'convertTime'>;
|
|
289
|
+
export type RunOptions<A> = {
|
|
290
|
+
/** What the page fixed: the AI neither sees nor changes it. */
|
|
291
|
+
prefill?: PrefillOf<A>;
|
|
292
|
+
/** The rows the AI chooses a row parameter among (35 §2): `{ order: choose(orders, label) }`. */
|
|
293
|
+
options?: {
|
|
294
|
+
[K in keyof A]?: ChooseParam;
|
|
295
|
+
};
|
|
296
|
+
/** How to fill each parameter here (31 §7): the function says what it takes, the page how to fill it. */
|
|
297
|
+
args?: {
|
|
298
|
+
[K in keyof A]?: string;
|
|
299
|
+
};
|
|
300
|
+
};
|
|
301
|
+
/** What `run()` takes as its handle: a company function (`fn.x`) or a page action (`act.x`). */
|
|
302
|
+
export type AnyRunHandle = {
|
|
303
|
+
readonly [HANDLE]: 'function' | 'action';
|
|
304
|
+
readonly name: string;
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* `say` of a `run()`: said while a company function runs, per language (66). A page action runs at once,
|
|
308
|
+
* next to the database: it takes none, and the type says so.
|
|
309
|
+
*/
|
|
310
|
+
export type SayOf<H> = [H] extends [{
|
|
311
|
+
readonly [HANDLE]: 'function';
|
|
312
|
+
}] ? Spoken : 'say is for a company function (fn.x): a page action runs at once';
|
|
313
|
+
/** The `args` `run()` checks: its handle's. */
|
|
314
|
+
export type RunArgs<H> = HandleArgs<H>;
|
|
315
|
+
type Same<X, Y> = (<T>() => T extends X ? 1 : 2) extends <T>() => (T extends Y ? 1 : 2) ? true : false;
|
|
316
|
+
/** `true` when two of the args in `U` are not the same type. */
|
|
317
|
+
type ArgsDiffer<U, All = U> = U extends unknown ? (All extends unknown ? (Same<U, All> extends true ? never : true) : never) : never;
|
|
318
|
+
/**
|
|
319
|
+
* A handle that may be one of several (`fn[name]`, `flag ? act.a : act.b`) is one `run()` only when they
|
|
320
|
+
* all take the same args (76 §2.15): each checks the parameters it is given exactly, so prefill for one
|
|
321
|
+
* is wrong for another. Different args: one `run()` per branch.
|
|
322
|
+
*/
|
|
323
|
+
export type SameArgs<H> = [ArgsDiffer<HandleArgs<H>>] extends [never] ? unknown : {
|
|
324
|
+
readonly 'run() of one of several handles that take different args: write one run() per branch, flag ? run(a, …) : run(b, …)': never;
|
|
325
|
+
};
|
|
326
|
+
/**
|
|
327
|
+
* Run a company function (`fn.x`) or a page action (`act.x`, 76 §2.11). Two signatures: every
|
|
328
|
+
* required parameter prefilled (what `doNow()` takes), or some left for the AI.
|
|
329
|
+
*/
|
|
330
|
+
export declare function run<H extends AnyRunHandle, K extends string | undefined = undefined>(handle: H & SameArgs<H>, options: ([RequiredKeys<RunArgs<H>>] extends [never] ? {
|
|
331
|
+
prefill?: PrefillOf<RunArgs<H>>;
|
|
332
|
+
} : {
|
|
333
|
+
prefill: FullPrefill<RunArgs<H>>;
|
|
334
|
+
}) & {
|
|
335
|
+
options?: undefined;
|
|
336
|
+
args?: undefined;
|
|
337
|
+
say?: SayOf<H>;
|
|
338
|
+
runKey?: K;
|
|
339
|
+
}): RunAction<KeyedOf<K>, AllPrefilled>;
|
|
340
|
+
export declare function run<H extends AnyRunHandle, K extends string | undefined = undefined>(handle: H & SameArgs<H>, options?: RunOptions<RunArgs<H>> & {
|
|
341
|
+
say?: SayOf<H>;
|
|
342
|
+
runKey?: K;
|
|
343
|
+
}): RunAction<KeyedOf<K>, LeftForAi>;
|
|
344
|
+
/** Add a row (15 §10.6): `fields` are what the AI fills, `prefill` what the page fixed, `options` a ref field's rows. */
|
|
345
|
+
export declare function createRow<K extends string | undefined = undefined>(table: string, options: {
|
|
346
|
+
fields: readonly string[];
|
|
347
|
+
required?: readonly string[];
|
|
348
|
+
prefill?: Record<string, unknown>;
|
|
349
|
+
options?: Record<string, ChooseParam>;
|
|
350
|
+
runKey?: K;
|
|
351
|
+
}): Action<'createRow', KeyedOf<K>, AllPrefilled>;
|
|
352
|
+
/** Delete a row and everything under it (15 §10.6.1). */
|
|
353
|
+
export declare function deleteRow<K extends string | undefined = undefined>(row: PageRow | string, options?: {
|
|
354
|
+
reason?: string;
|
|
355
|
+
runKey?: K;
|
|
356
|
+
}): Action<'deleteRow', KeyedOf<K>, AllPrefilled>;
|
|
357
|
+
/** What every transfer takes (76 §2.9). */
|
|
358
|
+
export type TransferOptions = {
|
|
359
|
+
/** E.164 number, or a SIP URI (`sip:desk@pbx.example.com`). */
|
|
360
|
+
to: string;
|
|
361
|
+
/** What the person hears about the call before it is put through, in their `language`. */
|
|
362
|
+
briefing?: string;
|
|
363
|
+
/** The language of the person taking the call (BCP-47; default `en`): the briefing is said in it, they are heard in it. */
|
|
364
|
+
language?: string;
|
|
365
|
+
/** A SIP `to` that asks for credentials: kept on the server. */
|
|
366
|
+
sipAuth?: {
|
|
367
|
+
username: string;
|
|
368
|
+
password: string;
|
|
369
|
+
};
|
|
370
|
+
/** The caller ID the person sees: the customer's number or ours. */
|
|
371
|
+
callerId?: 'customer' | 'service';
|
|
372
|
+
};
|
|
373
|
+
/**
|
|
374
|
+
* A transfer the person confirms (76 §2.9): `whisper` is what they hear, on a loop, when they pick up,
|
|
375
|
+
* before they confirm: who it is and what about. The platform adds how to confirm. Said in English for now.
|
|
376
|
+
*/
|
|
377
|
+
export type WarmTransferOptions = TransferOptions & {
|
|
378
|
+
whisper?: string;
|
|
379
|
+
};
|
|
380
|
+
export type BackgroundTransferOptions = WarmTransferOptions & {
|
|
381
|
+
/** What is said as the two are put through: to the person (`{{briefing}}`), to the customer per language. */
|
|
382
|
+
bridge?: {
|
|
383
|
+
person?: string;
|
|
384
|
+
customer?: Spoken;
|
|
385
|
+
};
|
|
386
|
+
};
|
|
387
|
+
/** Put the customer through; the person hears the briefing first and does not confirm (76 §2.9). */
|
|
388
|
+
export declare function coldTransfer<K extends string | undefined = undefined>(options: TransferOptions & {
|
|
389
|
+
runKey?: K;
|
|
390
|
+
}): TransferVerbAction<KeyedOf<K>>;
|
|
391
|
+
/** The customer waits; the person confirms, hears the briefing, then is put through (76 §2.9). */
|
|
392
|
+
export declare function warmTransfer<K extends string | undefined = undefined>(options: WarmTransferOptions & {
|
|
393
|
+
runKey?: K;
|
|
394
|
+
}): TransferVerbAction<KeyedOf<K>>;
|
|
395
|
+
/** The AI keeps talking with the customer while the person is called; put through once they take it (76 §2.9). */
|
|
396
|
+
export declare function backgroundTransfer<K extends string | undefined = undefined>(options: BackgroundTransferOptions & {
|
|
397
|
+
runKey?: K;
|
|
398
|
+
}): TransferVerbAction<KeyedOf<K>>;
|
|
399
|
+
/** End the conversation (a call hangs up once the last line has played). */
|
|
400
|
+
export declare function end<K extends string | undefined = undefined>(options?: {
|
|
401
|
+
runKey?: K;
|
|
402
|
+
}): Action<'end', KeyedOf<K>, AllPrefilled>;
|
|
403
|
+
/** Leave a message on the voicemail, word for word, then hang up (25 §13). */
|
|
404
|
+
export declare function voicemail<K extends string | undefined = undefined>(options: {
|
|
405
|
+
text: Spoken;
|
|
406
|
+
runKey?: K;
|
|
407
|
+
}): Action<'voicemail', KeyedOf<K>, AllPrefilled>;
|
|
408
|
+
/** Ask the customer to press a key; what they press is written to `write` (through `map`). */
|
|
409
|
+
export declare function keypad(options: {
|
|
410
|
+
runKey: string;
|
|
411
|
+
say: Spoken;
|
|
412
|
+
digits: string[];
|
|
413
|
+
timeoutMs?: number;
|
|
414
|
+
write?: Slot | SlotRef;
|
|
415
|
+
map?: Record<string, string | number | boolean>;
|
|
416
|
+
}): Action<'keypad', RunKeyGiven, AllPrefilled>;
|
|
417
|
+
/** Book the case's next step (40 §2.2), or move one already booked (51 §2). The AI gives when, in UTC (76 §2.19). */
|
|
418
|
+
export declare function scheduleFollowUp(options: {
|
|
419
|
+
channels: Array<'call' | 'sms' | 'email'>;
|
|
420
|
+
/** What the page fixed: the channel, or whom (a contact's id). */
|
|
421
|
+
prefill?: {
|
|
422
|
+
channel?: 'call' | 'sms' | 'email';
|
|
423
|
+
contactId?: string;
|
|
424
|
+
};
|
|
425
|
+
/** The contacts the AI chooses among: `{ contactId: choose(contacts, label) }`. */
|
|
426
|
+
options?: {
|
|
427
|
+
contactId: ChooseParam;
|
|
428
|
+
};
|
|
429
|
+
runKey?: string;
|
|
430
|
+
}): FollowUpVerbAction<'scheduleFollowUp'>;
|
|
431
|
+
/** Cancel the case's next step (40 §2.2): the AI says why. */
|
|
432
|
+
export declare function cancelFollowUp(options?: {
|
|
433
|
+
runKey?: string;
|
|
434
|
+
}): FollowUpVerbAction<'cancelFollowUp'>;
|
|
435
|
+
/** Say a fixed text, word for word (a compliance statement): `doNow()` only. `answers`: it answers what the customer said. */
|
|
436
|
+
export declare function announce(options: {
|
|
437
|
+
runKey: string;
|
|
438
|
+
text: Spoken;
|
|
439
|
+
answers?: boolean;
|
|
440
|
+
}): AnnounceVerbAction;
|
|
441
|
+
/** `fn` of `__gen` (76 §2.15): a handle per company function, by name; the types say which names there are. */
|
|
442
|
+
export declare function functionHandles(): Record<string, FunctionHandle>;
|
|
443
|
+
/** `act` of `__gen` (76 §2.11): a handle per page action of `actions.ts`, by name; the types say which names there are. */
|
|
444
|
+
export declare function actionHandles(): Record<string, PageActionHandle>;
|
|
445
|
+
/** What a page function returned, as the platform reads it: `page()` or `doNow()`, as its envelope. */
|
|
446
|
+
export declare function toFnPageResult(value: unknown): Envelope;
|
|
447
|
+
export {};
|
|
448
|
+
//# sourceMappingURL=fns.d.ts.map
|