digital-tools 2.1.3 → 2.3.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/CHANGELOG.md +9 -0
- package/README.md +2 -0
- package/dist/client.d.ts +109 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +69 -0
- package/dist/client.js.map +1 -0
- package/dist/define.d.ts +2 -2
- package/dist/define.d.ts.map +1 -1
- package/dist/define.js +21 -11
- package/dist/define.js.map +1 -1
- package/dist/function-ref.d.ts +229 -0
- package/dist/function-ref.d.ts.map +1 -0
- package/dist/function-ref.js +28 -0
- package/dist/function-ref.js.map +1 -0
- package/dist/function-sugar.d.ts +57 -0
- package/dist/function-sugar.d.ts.map +1 -0
- package/dist/function-sugar.js +79 -0
- package/dist/function-sugar.js.map +1 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -4
- package/dist/index.js.map +1 -1
- package/dist/providers/analytics/mixpanel.d.ts.map +1 -1
- package/dist/providers/analytics/mixpanel.js +21 -18
- package/dist/providers/analytics/mixpanel.js.map +1 -1
- package/dist/providers/calendar/cal-com.d.ts.map +1 -1
- package/dist/providers/calendar/cal-com.js +10 -10
- package/dist/providers/calendar/cal-com.js.map +1 -1
- package/dist/providers/calendar/google-calendar.d.ts.map +1 -1
- package/dist/providers/calendar/google-calendar.js +4 -4
- package/dist/providers/calendar/google-calendar.js.map +1 -1
- package/dist/providers/crm/hubspot.d.ts.map +1 -1
- package/dist/providers/crm/hubspot.js +107 -85
- package/dist/providers/crm/hubspot.js.map +1 -1
- package/dist/providers/development/github.d.ts.map +1 -1
- package/dist/providers/development/github.js +40 -43
- package/dist/providers/development/github.js.map +1 -1
- package/dist/providers/ecommerce/shopify.d.ts.map +1 -1
- package/dist/providers/ecommerce/shopify.js +79 -62
- package/dist/providers/ecommerce/shopify.js.map +1 -1
- package/dist/providers/email/resend.d.ts.map +1 -1
- package/dist/providers/email/resend.js +20 -16
- package/dist/providers/email/resend.js.map +1 -1
- package/dist/providers/email/sendgrid.d.ts.map +1 -1
- package/dist/providers/email/sendgrid.js +12 -9
- package/dist/providers/email/sendgrid.js.map +1 -1
- package/dist/providers/finance/stripe.d.ts.map +1 -1
- package/dist/providers/finance/stripe.js +44 -42
- package/dist/providers/finance/stripe.js.map +1 -1
- package/dist/providers/forms/typeform.d.ts.map +1 -1
- package/dist/providers/forms/typeform.js +68 -58
- package/dist/providers/forms/typeform.js.map +1 -1
- package/dist/providers/knowledge/notion.d.ts.map +1 -1
- package/dist/providers/knowledge/notion.js +75 -41
- package/dist/providers/knowledge/notion.js.map +1 -1
- package/dist/providers/marketing/mailchimp.d.ts.map +1 -1
- package/dist/providers/marketing/mailchimp.js +74 -61
- package/dist/providers/marketing/mailchimp.js.map +1 -1
- package/dist/providers/media/cloudinary.d.ts.map +1 -1
- package/dist/providers/media/cloudinary.js +30 -28
- package/dist/providers/media/cloudinary.js.map +1 -1
- package/dist/providers/messaging/slack.d.ts.map +1 -1
- package/dist/providers/messaging/slack.js +75 -58
- package/dist/providers/messaging/slack.js.map +1 -1
- package/dist/providers/messaging/twilio-sms.d.ts.map +1 -1
- package/dist/providers/messaging/twilio-sms.js +33 -15
- package/dist/providers/messaging/twilio-sms.js.map +1 -1
- package/dist/providers/project-management/linear.d.ts.map +1 -1
- package/dist/providers/project-management/linear.js +31 -27
- package/dist/providers/project-management/linear.js.map +1 -1
- package/dist/providers/spreadsheet/google-sheets.d.ts.map +1 -1
- package/dist/providers/spreadsheet/google-sheets.js +21 -18
- package/dist/providers/spreadsheet/google-sheets.js.map +1 -1
- package/dist/providers/spreadsheet/xlsx.d.ts.map +1 -1
- package/dist/providers/spreadsheet/xlsx.js +4 -4
- package/dist/providers/spreadsheet/xlsx.js.map +1 -1
- package/dist/providers/storage/index.js +1 -0
- package/dist/providers/storage/index.js.map +1 -1
- package/dist/providers/storage/s3.d.ts.map +1 -1
- package/dist/providers/storage/s3.js +36 -27
- package/dist/providers/storage/s3.js.map +1 -1
- package/dist/providers/support/zendesk.d.ts.map +1 -1
- package/dist/providers/support/zendesk.js +24 -25
- package/dist/providers/support/zendesk.js.map +1 -1
- package/dist/providers/tasks/todoist.d.ts.map +1 -1
- package/dist/providers/tasks/todoist.js +18 -18
- package/dist/providers/tasks/todoist.js.map +1 -1
- package/dist/providers/video-conferencing/google-meet.d.ts.map +1 -1
- package/dist/providers/video-conferencing/google-meet.js +11 -11
- package/dist/providers/video-conferencing/google-meet.js.map +1 -1
- package/dist/providers/video-conferencing/jitsi.js +14 -14
- package/dist/providers/video-conferencing/jitsi.js.map +1 -1
- package/dist/providers/video-conferencing/teams.d.ts.map +1 -1
- package/dist/providers/video-conferencing/teams.js +9 -7
- package/dist/providers/video-conferencing/teams.js.map +1 -1
- package/dist/providers/video-conferencing/zoom.d.ts.map +1 -1
- package/dist/providers/video-conferencing/zoom.js +26 -24
- package/dist/providers/video-conferencing/zoom.js.map +1 -1
- package/dist/tools/data.d.ts.map +1 -1
- package/dist/tools/data.js +5 -12
- package/dist/tools/data.js.map +1 -1
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +1 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/system.d.ts +289 -0
- package/dist/tools/system.d.ts.map +1 -0
- package/dist/tools/system.js +752 -0
- package/dist/tools/system.js.map +1 -0
- package/dist/tools/web.d.ts.map +1 -1
- package/dist/tools/web.js +22 -10
- package/dist/tools/web.js.map +1 -1
- package/dist/track-record.d.ts +101 -0
- package/dist/track-record.d.ts.map +1 -0
- package/dist/track-record.js +17 -0
- package/dist/track-record.js.map +1 -0
- package/dist/types.d.ts +210 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/verb-registration.d.ts +122 -0
- package/dist/verb-registration.d.ts.map +1 -0
- package/dist/verb-registration.js +176 -0
- package/dist/verb-registration.js.map +1 -0
- package/dist/worker.d.ts +93 -0
- package/dist/worker.d.ts.map +1 -0
- package/dist/worker.js +315 -0
- package/dist/worker.js.map +1 -0
- package/dist/wrap.d.ts +89 -0
- package/dist/wrap.d.ts.map +1 -0
- package/dist/wrap.js +225 -0
- package/dist/wrap.js.map +1 -0
- package/package.json +31 -14
- package/src/client.ts +136 -0
- package/src/define.ts +30 -24
- package/src/function-ref.ts +264 -0
- package/src/function-sugar.ts +134 -0
- package/src/index.ts +132 -10
- package/src/providers/analytics/mixpanel.ts +19 -18
- package/src/providers/calendar/cal-com.ts +29 -18
- package/src/providers/calendar/google-calendar.ts +20 -14
- package/src/providers/crm/hubspot.ts +225 -99
- package/src/providers/development/github.ts +206 -135
- package/src/providers/ecommerce/shopify.ts +250 -89
- package/src/providers/email/resend.ts +101 -28
- package/src/providers/email/sendgrid.ts +12 -9
- package/src/providers/finance/stripe.ts +128 -49
- package/src/providers/forms/typeform.ts +74 -58
- package/src/providers/knowledge/notion.ts +340 -88
- package/src/providers/marketing/mailchimp.ts +86 -70
- package/src/providers/media/cloudinary.ts +99 -41
- package/src/providers/messaging/slack.ts +283 -85
- package/src/providers/messaging/twilio-sms.ts +35 -15
- package/src/providers/project-management/linear.ts +143 -55
- package/src/providers/spreadsheet/google-sheets.ts +222 -56
- package/src/providers/spreadsheet/xlsx.ts +47 -16
- package/src/providers/storage/s3.ts +119 -47
- package/src/providers/support/zendesk.ts +196 -46
- package/src/providers/tasks/todoist.ts +20 -26
- package/src/providers/video-conferencing/google-meet.ts +17 -20
- package/src/providers/video-conferencing/jitsi.ts +14 -14
- package/src/providers/video-conferencing/teams.ts +14 -13
- package/src/providers/video-conferencing/zoom.ts +54 -49
- package/src/tools/data.ts +6 -16
- package/src/tools/index.ts +1 -0
- package/src/tools/system.ts +887 -0
- package/src/tools/web.ts +22 -10
- package/src/track-record.ts +106 -0
- package/src/types.ts +241 -13
- package/src/verb-registration.ts +197 -0
- package/src/worker.ts +370 -0
- package/src/wrap.ts +260 -0
- package/test/client.test.ts +146 -0
- package/test/communication-tools-extended.test.ts +734 -0
- package/test/data-tools-extended.test.ts +743 -0
- package/test/define-extended.test.ts +819 -0
- package/test/define.test.ts +150 -41
- package/test/entities.test.ts +623 -0
- package/test/extended-entities.test.ts +1228 -0
- package/test/provider-implementations.test.ts +725 -0
- package/test/provider-registry-extended.test.ts +583 -0
- package/test/providers/google-sheets.test.ts +851 -0
- package/test/providers/helpers.ts +554 -0
- package/test/providers/hubspot.test.ts +576 -0
- package/test/providers/slack.test.ts +932 -0
- package/test/providers/stripe.test.ts +701 -0
- package/test/providers.test.ts +578 -0
- package/test/system-tools-extended.test.ts +632 -0
- package/test/system.test.ts +673 -0
- package/test/tools.test.ts +15 -11
- package/test/types.test.ts +402 -0
- package/test/verb-registration.test.ts +395 -0
- package/test/web-tools.test.ts +553 -0
- package/test/worker-extended.test.ts +699 -0
- package/test/worker.test.ts +576 -0
- package/test/wrap.test.ts +366 -0
- package/tsconfig.json +3 -13
- package/vitest.config.ts +37 -0
- package/wrangler.jsonc +9 -0
- package/.turbo/turbo-build.log +0 -4
- package/LICENSE +0 -21
- package/dist/providers/voice/vapi.d.ts +0 -27
- package/dist/providers/voice/vapi.d.ts.map +0 -1
- package/dist/providers/voice/vapi.js +0 -440
- package/dist/providers/voice/vapi.js.map +0 -1
- package/src/define.js +0 -259
- package/src/entities/advertising.js +0 -999
- package/src/entities/ai.js +0 -756
- package/src/entities/analytics.js +0 -1588
- package/src/entities/automation.js +0 -601
- package/src/entities/communication.js +0 -1150
- package/src/entities/crm.js +0 -1386
- package/src/entities/design.js +0 -546
- package/src/entities/development.js +0 -2212
- package/src/entities/document.js +0 -874
- package/src/entities/ecommerce.js +0 -1429
- package/src/entities/experiment.js +0 -1039
- package/src/entities/finance.js +0 -3478
- package/src/entities/forms.js +0 -1892
- package/src/entities/hr.js +0 -661
- package/src/entities/identity.js +0 -997
- package/src/entities/index.js +0 -282
- package/src/entities/infrastructure.js +0 -1153
- package/src/entities/knowledge.js +0 -1438
- package/src/entities/marketing.js +0 -1610
- package/src/entities/media.js +0 -1634
- package/src/entities/notification.js +0 -1199
- package/src/entities/presentation.js +0 -1274
- package/src/entities/productivity.js +0 -1317
- package/src/entities/project-management.js +0 -1136
- package/src/entities/recruiting.js +0 -736
- package/src/entities/shipping.js +0 -509
- package/src/entities/signature.js +0 -1102
- package/src/entities/site.js +0 -222
- package/src/entities/spreadsheet.js +0 -1341
- package/src/entities/storage.js +0 -1198
- package/src/entities/support.js +0 -1166
- package/src/entities/video-conferencing.js +0 -1750
- package/src/entities/video.js +0 -950
- package/src/entities.js +0 -1663
- package/src/index.js +0 -74
- package/src/providers/analytics/index.js +0 -17
- package/src/providers/analytics/mixpanel.js +0 -255
- package/src/providers/calendar/cal-com.js +0 -303
- package/src/providers/calendar/google-calendar.js +0 -335
- package/src/providers/calendar/index.js +0 -20
- package/src/providers/crm/hubspot.js +0 -566
- package/src/providers/crm/index.js +0 -17
- package/src/providers/development/github.js +0 -472
- package/src/providers/development/index.js +0 -17
- package/src/providers/ecommerce/index.js +0 -17
- package/src/providers/ecommerce/shopify.js +0 -378
- package/src/providers/email/index.js +0 -20
- package/src/providers/email/resend.js +0 -258
- package/src/providers/email/sendgrid.js +0 -161
- package/src/providers/finance/index.js +0 -17
- package/src/providers/finance/stripe.js +0 -549
- package/src/providers/forms/index.js +0 -17
- package/src/providers/forms/typeform.js +0 -500
- package/src/providers/index.js +0 -123
- package/src/providers/knowledge/index.js +0 -17
- package/src/providers/knowledge/notion.js +0 -389
- package/src/providers/marketing/index.js +0 -17
- package/src/providers/marketing/mailchimp.js +0 -443
- package/src/providers/media/cloudinary.js +0 -318
- package/src/providers/media/index.js +0 -17
- package/src/providers/messaging/index.js +0 -20
- package/src/providers/messaging/slack.js +0 -393
- package/src/providers/messaging/twilio-sms.js +0 -249
- package/src/providers/project-management/index.js +0 -17
- package/src/providers/project-management/linear.js +0 -575
- package/src/providers/registry.js +0 -86
- package/src/providers/spreadsheet/google-sheets.js +0 -375
- package/src/providers/spreadsheet/index.js +0 -20
- package/src/providers/spreadsheet/xlsx.js +0 -423
- package/src/providers/storage/index.js +0 -24
- package/src/providers/storage/s3.js +0 -419
- package/src/providers/support/index.js +0 -17
- package/src/providers/support/zendesk.js +0 -373
- package/src/providers/tasks/index.js +0 -17
- package/src/providers/tasks/todoist.js +0 -286
- package/src/providers/types.js +0 -9
- package/src/providers/video-conferencing/google-meet.js +0 -286
- package/src/providers/video-conferencing/index.js +0 -31
- package/src/providers/video-conferencing/jitsi.js +0 -254
- package/src/providers/video-conferencing/teams.js +0 -270
- package/src/providers/video-conferencing/zoom.js +0 -332
- package/src/registry.js +0 -128
- package/src/tools/communication.js +0 -184
- package/src/tools/data.js +0 -205
- package/src/tools/index.js +0 -11
- package/src/tools/web.js +0 -137
- package/src/types.js +0 -10
- package/test/define.test.js +0 -306
- package/test/registry.test.js +0 -357
- package/test/tools.test.js +0 -363
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sugar factories for the Four Functions (v3 §6).
|
|
3
|
+
*
|
|
4
|
+
* Top-level named exports `Code` / `Generative` / `Agentic` / `Human` mint a
|
|
5
|
+
* typed {@link FunctionRef} from a kind-specific spec. The factory fills in
|
|
6
|
+
* the discriminator (`kind`) and a deterministic `$id` derived from `name`,
|
|
7
|
+
* so callers write the minimum possible at the call site:
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { Code, Generative, Agentic, Human } from 'digital-tools'
|
|
11
|
+
*
|
|
12
|
+
* const summarize = Generative({ name: 'summarize', modelHint: 'claude-opus-4' })
|
|
13
|
+
* const reviewer = Agentic({ name: 'security-review', mode: 'supervised', persona: 'persona:skeptic' })
|
|
14
|
+
* const signOff = Human({ name: 'controller-sign-off', rationale: 'regulatory',
|
|
15
|
+
* expirationPolicy: { whenAccuracyExceeds: 0.99, whenSamplesExceed: 500 } })
|
|
16
|
+
* const compute = Code({ name: 'compute-vat', handler: (x: { net: number }) => x.net * 0.2 })
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
* @packageDocumentation
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
import type {
|
|
23
|
+
AgenticFunctionRef,
|
|
24
|
+
CodeFunctionRef,
|
|
25
|
+
FunctionRef,
|
|
26
|
+
GenerativeFunctionRef,
|
|
27
|
+
HumanFunctionRef,
|
|
28
|
+
} from './function-ref.js'
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Reduce an arbitrary name to a stable, lowercase, hyphen-joined slug.
|
|
32
|
+
* Non-ASCII alphanumerics collapse to `-`; leading/trailing `-` are trimmed.
|
|
33
|
+
*/
|
|
34
|
+
function slug(name: string): string {
|
|
35
|
+
return name
|
|
36
|
+
.toLowerCase()
|
|
37
|
+
.replace(/[^a-z0-9]+/g, '-')
|
|
38
|
+
.replace(/^-+|-+$/g, '')
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Mint a deterministic `fn:<kind>:<slug>` MDXLD `$id`.
|
|
43
|
+
*/
|
|
44
|
+
function mintId(kind: FunctionRef['kind'], name: string): string {
|
|
45
|
+
return `fn:${kind}:${slug(name)}`
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// ============================================================================
|
|
49
|
+
// Code
|
|
50
|
+
// ============================================================================
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Spec accepted by the {@link Code} sugar factory. Omits the auto-derived
|
|
54
|
+
* `$id` and the discriminator `kind`.
|
|
55
|
+
*/
|
|
56
|
+
export type CodeFunctionSpec<TInput = unknown, TOutput = unknown> = Omit<
|
|
57
|
+
CodeFunctionRef<TInput, TOutput>,
|
|
58
|
+
'$id' | 'kind'
|
|
59
|
+
>
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Mint a {@link CodeFunctionRef}. The `handler` may be an inline function or
|
|
63
|
+
* an `ActionRef` string into `digital-objects`.
|
|
64
|
+
*/
|
|
65
|
+
export function Code<TInput = unknown, TOutput = unknown>(
|
|
66
|
+
spec: CodeFunctionSpec<TInput, TOutput>
|
|
67
|
+
): CodeFunctionRef<TInput, TOutput> {
|
|
68
|
+
return {
|
|
69
|
+
$id: mintId('code', spec.name),
|
|
70
|
+
kind: 'code',
|
|
71
|
+
...spec,
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ============================================================================
|
|
76
|
+
// Generative
|
|
77
|
+
// ============================================================================
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Spec accepted by the {@link Generative} sugar factory.
|
|
81
|
+
*/
|
|
82
|
+
export type GenerativeFunctionSpec = Omit<GenerativeFunctionRef, '$id' | 'kind'>
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Mint a {@link GenerativeFunctionRef} — single-shot LLM call.
|
|
86
|
+
*/
|
|
87
|
+
export function Generative(spec: GenerativeFunctionSpec): GenerativeFunctionRef {
|
|
88
|
+
return {
|
|
89
|
+
$id: mintId('generative', spec.name),
|
|
90
|
+
kind: 'generative',
|
|
91
|
+
...spec,
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// ============================================================================
|
|
96
|
+
// Agentic
|
|
97
|
+
// ============================================================================
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Spec accepted by the {@link Agentic} sugar factory.
|
|
101
|
+
*/
|
|
102
|
+
export type AgenticFunctionSpec = Omit<AgenticFunctionRef, '$id' | 'kind'>
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Mint an {@link AgenticFunctionRef} — looping, tool-using AI worker.
|
|
106
|
+
*/
|
|
107
|
+
export function Agentic(spec: AgenticFunctionSpec): AgenticFunctionRef {
|
|
108
|
+
return {
|
|
109
|
+
$id: mintId('agentic', spec.name),
|
|
110
|
+
kind: 'agentic',
|
|
111
|
+
...spec,
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// ============================================================================
|
|
116
|
+
// Human
|
|
117
|
+
// ============================================================================
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Spec accepted by the {@link Human} sugar factory.
|
|
121
|
+
*/
|
|
122
|
+
export type HumanFunctionSpec = Omit<HumanFunctionRef, '$id' | 'kind'>
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Mint a {@link HumanFunctionRef} — work performed by a person, with a
|
|
126
|
+
* declared rationale and migration policy.
|
|
127
|
+
*/
|
|
128
|
+
export function Human(spec: HumanFunctionSpec): HumanFunctionRef {
|
|
129
|
+
return {
|
|
130
|
+
$id: mintId('human', spec.name),
|
|
131
|
+
kind: 'human',
|
|
132
|
+
...spec,
|
|
133
|
+
}
|
|
134
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -12,11 +12,47 @@
|
|
|
12
12
|
* @packageDocumentation
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
// Export all types
|
|
15
|
+
// Export all types from types.ts
|
|
16
16
|
export type * from './types.js'
|
|
17
17
|
|
|
18
|
-
// Re-export
|
|
19
|
-
|
|
18
|
+
// Re-export commonly used types explicitly for better discoverability
|
|
19
|
+
// Core types
|
|
20
|
+
export type {
|
|
21
|
+
Tool,
|
|
22
|
+
AnyTool,
|
|
23
|
+
ToolCategory,
|
|
24
|
+
ToolSubcategory,
|
|
25
|
+
// Execution types
|
|
26
|
+
ToolResult,
|
|
27
|
+
ToolContext,
|
|
28
|
+
// Configuration types
|
|
29
|
+
ToolParameter,
|
|
30
|
+
ToolOutput,
|
|
31
|
+
ToolPermission,
|
|
32
|
+
ToolAudience,
|
|
33
|
+
// Registry types
|
|
34
|
+
ToolRegistry,
|
|
35
|
+
ToolQuery,
|
|
36
|
+
// Builder types
|
|
37
|
+
DefineToolOptions,
|
|
38
|
+
// SVO co-design (aip-oejp): verb / frame / auth / pricing / handler ctx
|
|
39
|
+
Frame,
|
|
40
|
+
ActionRef,
|
|
41
|
+
IdentityRef,
|
|
42
|
+
PaymentRail,
|
|
43
|
+
PaymentRequired,
|
|
44
|
+
AuthRequirement,
|
|
45
|
+
ToolHandlerContext,
|
|
46
|
+
// id.org.ai canonical types re-exported via types.ts so consumers
|
|
47
|
+
// don't need a second import. Populated on `ToolHandlerContext` by
|
|
48
|
+
// `wrapTool()` (aip-lbtr).
|
|
49
|
+
Identity,
|
|
50
|
+
PaymentReceipt,
|
|
51
|
+
// MCP compatibility
|
|
52
|
+
MCPTool,
|
|
53
|
+
MCPToolCall,
|
|
54
|
+
MCPToolResult,
|
|
55
|
+
} from './types.js'
|
|
20
56
|
|
|
21
57
|
// Export entity type definitions (Nouns for digital tools)
|
|
22
58
|
export {
|
|
@@ -72,12 +108,64 @@ export {
|
|
|
72
108
|
} from './registry.js'
|
|
73
109
|
|
|
74
110
|
// Export tool definition helpers
|
|
111
|
+
export { defineTool, defineAndRegister, createToolExecutor, toolBuilder } from './define.js'
|
|
112
|
+
|
|
113
|
+
// Export broker-aware HTTP wrapper (aip-lbtr) — bridges Tool definitions
|
|
114
|
+
// to id.org.ai's AuthBroker + PaymentBroker so paid/auth-gated tools work
|
|
115
|
+
// declaratively without callers manually wiring brokers.
|
|
116
|
+
export { wrapTool } from './wrap.js'
|
|
117
|
+
|
|
118
|
+
// Export Verb auto-registration helpers (aip-47tm) — explicit, idempotent
|
|
119
|
+
// bridge from `defineTool({ verb, frame })` to `digital-objects`'
|
|
120
|
+
// provider-mediated `defineVerb()`. Callers wire this at startup
|
|
121
|
+
// (`registerToolVerbs`) or lazily per dispatch (`registerToolVerb`).
|
|
75
122
|
export {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
} from './
|
|
123
|
+
registerToolVerb,
|
|
124
|
+
registerToolVerbs,
|
|
125
|
+
bootstrapTools,
|
|
126
|
+
VerbRegistrationConflictError,
|
|
127
|
+
} from './verb-registration.js'
|
|
128
|
+
export type { VerbRegistrationProvider } from './verb-registration.js'
|
|
129
|
+
|
|
130
|
+
// FunctionRef discriminated union (v3 §6) — the Four Functions promoted to
|
|
131
|
+
// a typed primitive. Additive alongside the legacy `Tool` interface; no
|
|
132
|
+
// existing tools are migrated.
|
|
133
|
+
export type {
|
|
134
|
+
RewardSignal,
|
|
135
|
+
PersonaRef,
|
|
136
|
+
SignOffMode,
|
|
137
|
+
OversightPolicy,
|
|
138
|
+
BaseFunctionRef,
|
|
139
|
+
CodeFunctionRef,
|
|
140
|
+
GenerativeFunctionRef,
|
|
141
|
+
AgenticFunctionRef,
|
|
142
|
+
HumanFunctionRef,
|
|
143
|
+
HumanRationale,
|
|
144
|
+
HumanExpirationPolicy,
|
|
145
|
+
HumanChannel,
|
|
146
|
+
FunctionRef,
|
|
147
|
+
FunctionKind,
|
|
148
|
+
} from './function-ref.js'
|
|
149
|
+
|
|
150
|
+
// Track-record + autonomy ladder primitives (shared with digital-workers
|
|
151
|
+
// once that package re-exports them).
|
|
152
|
+
export type {
|
|
153
|
+
AgentMode,
|
|
154
|
+
TrendDirection,
|
|
155
|
+
TrackRecord,
|
|
156
|
+
PromotionRule,
|
|
157
|
+
PromotionPolicy,
|
|
158
|
+
} from './track-record.js'
|
|
159
|
+
|
|
160
|
+
// Sugar factories — top-level named exports per v3 §6 import style:
|
|
161
|
+
// import { Code, Generative, Agentic, Human } from 'digital-tools'
|
|
162
|
+
export type {
|
|
163
|
+
CodeFunctionSpec,
|
|
164
|
+
GenerativeFunctionSpec,
|
|
165
|
+
AgenticFunctionSpec,
|
|
166
|
+
HumanFunctionSpec,
|
|
167
|
+
} from './function-sugar.js'
|
|
168
|
+
export { Code, Generative, Agentic, Human } from './function-sugar.js'
|
|
81
169
|
|
|
82
170
|
// Export pre-built tools
|
|
83
171
|
export {
|
|
@@ -101,6 +189,39 @@ export {
|
|
|
101
189
|
sendNotification,
|
|
102
190
|
sendSms,
|
|
103
191
|
communicationTools,
|
|
192
|
+
|
|
193
|
+
// System tools (fsx.do, gitx.do, bashx.do integration)
|
|
194
|
+
// Filesystem (fsx.do)
|
|
195
|
+
fsRead,
|
|
196
|
+
fsWrite,
|
|
197
|
+
fsList,
|
|
198
|
+
fsDelete,
|
|
199
|
+
fsGlob,
|
|
200
|
+
fsGrep,
|
|
201
|
+
fsxTools,
|
|
202
|
+
|
|
203
|
+
// Git (gitx.do)
|
|
204
|
+
gitInit,
|
|
205
|
+
gitClone,
|
|
206
|
+
gitStatus,
|
|
207
|
+
gitAdd,
|
|
208
|
+
gitCommit,
|
|
209
|
+
gitLog,
|
|
210
|
+
gitDiff,
|
|
211
|
+
gitCheckout,
|
|
212
|
+
gitPush,
|
|
213
|
+
gitPull,
|
|
214
|
+
gitxTools,
|
|
215
|
+
|
|
216
|
+
// Bash (bashx.do)
|
|
217
|
+
bashExec,
|
|
218
|
+
bashAnalyze,
|
|
219
|
+
bashScript,
|
|
220
|
+
bashEnv,
|
|
221
|
+
bashxTools,
|
|
222
|
+
|
|
223
|
+
// All system tools
|
|
224
|
+
systemTools,
|
|
104
225
|
} from './tools/index.js'
|
|
105
226
|
|
|
106
227
|
// Export providers (concrete implementations using third-party APIs)
|
|
@@ -158,12 +279,13 @@ import { registry } from './registry.js'
|
|
|
158
279
|
import { webTools } from './tools/web.js'
|
|
159
280
|
import { dataTools } from './tools/data.js'
|
|
160
281
|
import { communicationTools } from './tools/communication.js'
|
|
282
|
+
import { systemTools } from './tools/system.js'
|
|
161
283
|
|
|
162
284
|
/**
|
|
163
285
|
* Register all built-in tools in the global registry
|
|
164
286
|
*/
|
|
165
287
|
export function registerBuiltinTools(): void {
|
|
166
|
-
for (const tool of [...webTools, ...dataTools, ...communicationTools]) {
|
|
288
|
+
for (const tool of [...webTools, ...dataTools, ...communicationTools, ...systemTools]) {
|
|
167
289
|
registry.register(tool)
|
|
168
290
|
}
|
|
169
291
|
}
|
|
@@ -172,5 +294,5 @@ export function registerBuiltinTools(): void {
|
|
|
172
294
|
* Get all built-in tools
|
|
173
295
|
*/
|
|
174
296
|
export function getBuiltinTools() {
|
|
175
|
-
return [...webTools, ...dataTools, ...communicationTools]
|
|
297
|
+
return [...webTools, ...dataTools, ...communicationTools, ...systemTools]
|
|
176
298
|
}
|
|
@@ -47,8 +47,8 @@ export function createMixpanelProvider(config: ProviderConfig): AnalyticsProvide
|
|
|
47
47
|
info: mixpanelInfo,
|
|
48
48
|
|
|
49
49
|
async initialize(cfg: ProviderConfig): Promise<void> {
|
|
50
|
-
projectToken = cfg
|
|
51
|
-
apiSecret = cfg
|
|
50
|
+
projectToken = cfg['projectToken'] as string
|
|
51
|
+
apiSecret = cfg['apiSecret'] as string | undefined
|
|
52
52
|
|
|
53
53
|
if (!projectToken) {
|
|
54
54
|
throw new Error('Mixpanel project token is required')
|
|
@@ -76,7 +76,7 @@ export function createMixpanelProvider(config: ProviderConfig): AnalyticsProvide
|
|
|
76
76
|
body: JSON.stringify([testEvent]),
|
|
77
77
|
})
|
|
78
78
|
|
|
79
|
-
const result = await response.json() as { status: number }
|
|
79
|
+
const result = (await response.json()) as { status: number }
|
|
80
80
|
|
|
81
81
|
return {
|
|
82
82
|
healthy: response.ok && result.status === 1,
|
|
@@ -105,7 +105,9 @@ export function createMixpanelProvider(config: ProviderConfig): AnalyticsProvide
|
|
|
105
105
|
properties: {
|
|
106
106
|
token: projectToken,
|
|
107
107
|
distinct_id: event.userId || event.anonymousId || 'unknown',
|
|
108
|
-
time: event.timestamp
|
|
108
|
+
time: event.timestamp
|
|
109
|
+
? Math.floor(event.timestamp.getTime() / 1000)
|
|
110
|
+
: Math.floor(Date.now() / 1000),
|
|
109
111
|
$insert_id: `${event.event}_${Date.now()}_${Math.random().toString(36).substring(7)}`,
|
|
110
112
|
...event.properties,
|
|
111
113
|
},
|
|
@@ -119,7 +121,7 @@ export function createMixpanelProvider(config: ProviderConfig): AnalyticsProvide
|
|
|
119
121
|
body: JSON.stringify([eventData]),
|
|
120
122
|
})
|
|
121
123
|
|
|
122
|
-
const result = await response.json() as { status: number }
|
|
124
|
+
const result = (await response.json()) as { status: number }
|
|
123
125
|
return response.ok && result.status === 1
|
|
124
126
|
} catch (error) {
|
|
125
127
|
console.error('Mixpanel track error:', error)
|
|
@@ -143,7 +145,7 @@ export function createMixpanelProvider(config: ProviderConfig): AnalyticsProvide
|
|
|
143
145
|
body: JSON.stringify([engageData]),
|
|
144
146
|
})
|
|
145
147
|
|
|
146
|
-
const result = await response.json() as { status: number }
|
|
148
|
+
const result = (await response.json()) as { status: number }
|
|
147
149
|
return response.ok && result.status === 1
|
|
148
150
|
} catch (error) {
|
|
149
151
|
console.error('Mixpanel identify error:', error)
|
|
@@ -180,7 +182,7 @@ export function createMixpanelProvider(config: ProviderConfig): AnalyticsProvide
|
|
|
180
182
|
body: JSON.stringify([aliasEvent]),
|
|
181
183
|
})
|
|
182
184
|
|
|
183
|
-
const result = await response.json() as { status: number }
|
|
185
|
+
const result = (await response.json()) as { status: number }
|
|
184
186
|
return response.ok && result.status === 1
|
|
185
187
|
} catch (error) {
|
|
186
188
|
console.error('Mixpanel alias error:', error)
|
|
@@ -205,7 +207,7 @@ export function createMixpanelProvider(config: ProviderConfig): AnalyticsProvide
|
|
|
205
207
|
return null
|
|
206
208
|
}
|
|
207
209
|
|
|
208
|
-
const data = await response.json() as {
|
|
210
|
+
const data = (await response.json()) as {
|
|
209
211
|
name?: string
|
|
210
212
|
description?: string
|
|
211
213
|
query?: AnalyticsQueryOptions
|
|
@@ -216,9 +218,9 @@ export function createMixpanelProvider(config: ProviderConfig): AnalyticsProvide
|
|
|
216
218
|
return {
|
|
217
219
|
id: reportId,
|
|
218
220
|
name: data.name || reportId,
|
|
219
|
-
description: data.description,
|
|
221
|
+
...(data.description !== undefined && { description: data.description }),
|
|
220
222
|
query: data.query || { metrics: [], dateRange: { start: new Date(), end: new Date() } },
|
|
221
|
-
result: data.result,
|
|
223
|
+
...(data.result !== undefined && { result: data.result }),
|
|
222
224
|
createdAt: data.created ? new Date(data.created) : new Date(),
|
|
223
225
|
updatedAt: data.updated ? new Date(data.updated) : new Date(),
|
|
224
226
|
}
|
|
@@ -237,10 +239,11 @@ export function createMixpanelProvider(config: ProviderConfig): AnalyticsProvide
|
|
|
237
239
|
const auth = Buffer.from(`${apiSecret}:`).toString('base64')
|
|
238
240
|
|
|
239
241
|
// Construct query parameters
|
|
240
|
-
const params = new URLSearchParams(
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
242
|
+
const params = new URLSearchParams()
|
|
243
|
+
const fromDate = query.dateRange.start.toISOString().split('T')[0]
|
|
244
|
+
const toDate = query.dateRange.end.toISOString().split('T')[0]
|
|
245
|
+
if (fromDate) params.append('from_date', fromDate)
|
|
246
|
+
if (toDate) params.append('to_date', toDate)
|
|
244
247
|
|
|
245
248
|
if (query.metrics.length > 0) {
|
|
246
249
|
params.append('event', query.metrics.join(','))
|
|
@@ -251,9 +254,7 @@ export function createMixpanelProvider(config: ProviderConfig): AnalyticsProvide
|
|
|
251
254
|
}
|
|
252
255
|
|
|
253
256
|
// Use the segmentation endpoint for queries
|
|
254
|
-
const endpoint = query.dimensions && query.dimensions.length > 0
|
|
255
|
-
? 'segmentation'
|
|
256
|
-
: 'events'
|
|
257
|
+
const endpoint = query.dimensions && query.dimensions.length > 0 ? 'segmentation' : 'events'
|
|
257
258
|
|
|
258
259
|
const response = await fetch(`${MIXPANEL_QUERY_URL}/${endpoint}?${params.toString()}`, {
|
|
259
260
|
headers: {
|
|
@@ -265,7 +266,7 @@ export function createMixpanelProvider(config: ProviderConfig): AnalyticsProvide
|
|
|
265
266
|
throw new Error(`Query failed: ${response.statusText}`)
|
|
266
267
|
}
|
|
267
268
|
|
|
268
|
-
const data = await response.json() as {
|
|
269
|
+
const data = (await response.json()) as {
|
|
269
270
|
data?: Record<string, Record<string, number>>
|
|
270
271
|
}
|
|
271
272
|
|
|
@@ -30,7 +30,8 @@ const DEFAULT_BASE_URL = 'https://api.cal.com/v1'
|
|
|
30
30
|
export const calComInfo: ProviderInfo = {
|
|
31
31
|
id: 'calendar.cal-com',
|
|
32
32
|
name: 'Cal.com',
|
|
33
|
-
description:
|
|
33
|
+
description:
|
|
34
|
+
'Cal.com API for scheduling and calendar management (open-source Calendly alternative)',
|
|
34
35
|
category: 'calendar',
|
|
35
36
|
website: 'https://cal.com',
|
|
36
37
|
docsUrl: 'https://cal.com/docs/api-reference',
|
|
@@ -179,7 +180,7 @@ export function createCalComProvider(config: ProviderConfig): CalendarProvider {
|
|
|
179
180
|
.map((et) => ({
|
|
180
181
|
id: String(et.id),
|
|
181
182
|
name: et.title,
|
|
182
|
-
description: et.description,
|
|
183
|
+
...(et.description !== undefined && { description: et.description }),
|
|
183
184
|
timeZone: 'UTC', // Cal.com handles timezone per user
|
|
184
185
|
primary: et.position === 0,
|
|
185
186
|
accessRole: 'owner' as const,
|
|
@@ -204,7 +205,7 @@ export function createCalComProvider(config: ProviderConfig): CalendarProvider {
|
|
|
204
205
|
return {
|
|
205
206
|
id: String(et.id),
|
|
206
207
|
name: et.title,
|
|
207
|
-
description: et.description,
|
|
208
|
+
...(et.description !== undefined && { description: et.description }),
|
|
208
209
|
timeZone: 'UTC',
|
|
209
210
|
primary: et.position === 0,
|
|
210
211
|
accessRole: 'owner',
|
|
@@ -244,15 +245,18 @@ export function createCalComProvider(config: ProviderConfig): CalendarProvider {
|
|
|
244
245
|
id: booking.uid,
|
|
245
246
|
calendarId,
|
|
246
247
|
summary: booking.title,
|
|
247
|
-
description: booking.description,
|
|
248
|
-
location: booking.location,
|
|
248
|
+
...(booking.description !== undefined && { description: booking.description }),
|
|
249
|
+
...(booking.location !== undefined && { location: booking.location }),
|
|
249
250
|
start: new Date(booking.startTime),
|
|
250
251
|
end: new Date(booking.endTime),
|
|
251
252
|
attendees: booking.attendees.map((a) => ({
|
|
252
253
|
email: a.email,
|
|
253
254
|
responseStatus: booking.status === 'ACCEPTED' ? 'accepted' : 'needsAction',
|
|
254
255
|
})),
|
|
255
|
-
status: (booking.status === 'CANCELLED' ? 'cancelled' : 'confirmed') as
|
|
256
|
+
status: (booking.status === 'CANCELLED' ? 'cancelled' : 'confirmed') as
|
|
257
|
+
| 'confirmed'
|
|
258
|
+
| 'tentative'
|
|
259
|
+
| 'cancelled',
|
|
256
260
|
htmlLink: `${baseUrl.replace('/v1', '')}/booking/${booking.uid}`,
|
|
257
261
|
}
|
|
258
262
|
},
|
|
@@ -271,15 +275,18 @@ export function createCalComProvider(config: ProviderConfig): CalendarProvider {
|
|
|
271
275
|
id: booking.uid,
|
|
272
276
|
calendarId: String(booking.eventTypeId),
|
|
273
277
|
summary: booking.title,
|
|
274
|
-
description: booking.description,
|
|
275
|
-
location: booking.location,
|
|
278
|
+
...(booking.description !== undefined && { description: booking.description }),
|
|
279
|
+
...(booking.location !== undefined && { location: booking.location }),
|
|
276
280
|
start: new Date(booking.startTime),
|
|
277
281
|
end: new Date(booking.endTime),
|
|
278
282
|
attendees: booking.attendees.map((a) => ({
|
|
279
283
|
email: a.email,
|
|
280
284
|
responseStatus: booking.status === 'ACCEPTED' ? 'accepted' : 'needsAction',
|
|
281
285
|
})),
|
|
282
|
-
status: (booking.status === 'CANCELLED' ? 'cancelled' : 'confirmed') as
|
|
286
|
+
status: (booking.status === 'CANCELLED' ? 'cancelled' : 'confirmed') as
|
|
287
|
+
| 'confirmed'
|
|
288
|
+
| 'tentative'
|
|
289
|
+
| 'cancelled',
|
|
283
290
|
htmlLink: `${baseUrl.replace('/v1', '')}/booking/${booking.uid}`,
|
|
284
291
|
}
|
|
285
292
|
},
|
|
@@ -321,15 +328,18 @@ export function createCalComProvider(config: ProviderConfig): CalendarProvider {
|
|
|
321
328
|
id: booking.uid,
|
|
322
329
|
calendarId: String(booking.eventTypeId),
|
|
323
330
|
summary: booking.title,
|
|
324
|
-
description: booking.description,
|
|
325
|
-
location: booking.location,
|
|
331
|
+
...(booking.description !== undefined && { description: booking.description }),
|
|
332
|
+
...(booking.location !== undefined && { location: booking.location }),
|
|
326
333
|
start: new Date(booking.startTime),
|
|
327
334
|
end: new Date(booking.endTime),
|
|
328
335
|
attendees: booking.attendees.map((a) => ({
|
|
329
336
|
email: a.email,
|
|
330
337
|
responseStatus: booking.status === 'ACCEPTED' ? 'accepted' : 'needsAction',
|
|
331
338
|
})),
|
|
332
|
-
status: (booking.status === 'CANCELLED' ? 'cancelled' : 'confirmed') as
|
|
339
|
+
status: (booking.status === 'CANCELLED' ? 'cancelled' : 'confirmed') as
|
|
340
|
+
| 'confirmed'
|
|
341
|
+
| 'tentative'
|
|
342
|
+
| 'cancelled',
|
|
333
343
|
htmlLink: `${baseUrl.replace('/v1', '')}/booking/${booking.uid}`,
|
|
334
344
|
}
|
|
335
345
|
},
|
|
@@ -370,15 +380,18 @@ export function createCalComProvider(config: ProviderConfig): CalendarProvider {
|
|
|
370
380
|
id: booking.uid,
|
|
371
381
|
calendarId: String(booking.eventTypeId),
|
|
372
382
|
summary: booking.title,
|
|
373
|
-
description: booking.description,
|
|
374
|
-
location: booking.location,
|
|
383
|
+
...(booking.description !== undefined && { description: booking.description }),
|
|
384
|
+
...(booking.location !== undefined && { location: booking.location }),
|
|
375
385
|
start: new Date(booking.startTime),
|
|
376
386
|
end: new Date(booking.endTime),
|
|
377
387
|
attendees: booking.attendees.map((a) => ({
|
|
378
388
|
email: a.email,
|
|
379
389
|
responseStatus: booking.status === 'ACCEPTED' ? 'accepted' : 'needsAction',
|
|
380
390
|
})),
|
|
381
|
-
status: (booking.status === 'CANCELLED' ? 'cancelled' : 'confirmed') as
|
|
391
|
+
status: (booking.status === 'CANCELLED' ? 'cancelled' : 'confirmed') as
|
|
392
|
+
| 'confirmed'
|
|
393
|
+
| 'tentative'
|
|
394
|
+
| 'cancelled',
|
|
382
395
|
htmlLink: `${baseUrl.replace('/v1', '')}/booking/${booking.uid}`,
|
|
383
396
|
}))
|
|
384
397
|
|
|
@@ -402,9 +415,7 @@ export function createCalComProvider(config: ProviderConfig): CalendarProvider {
|
|
|
402
415
|
params.append('dateFrom', timeMin.toISOString())
|
|
403
416
|
params.append('dateTo', timeMax.toISOString())
|
|
404
417
|
|
|
405
|
-
const result = await apiRequest<CalComAvailability>(
|
|
406
|
-
`/availability?${params}`
|
|
407
|
-
)
|
|
418
|
+
const result = await apiRequest<CalComAvailability>(`/availability?${params}`)
|
|
408
419
|
|
|
409
420
|
if (result.ok && result.data) {
|
|
410
421
|
results.push({
|
|
@@ -85,8 +85,8 @@ export function createGoogleCalendarProvider(config: ProviderConfig): CalendarPr
|
|
|
85
85
|
info: googleCalendarInfo,
|
|
86
86
|
|
|
87
87
|
async initialize(cfg: ProviderConfig): Promise<void> {
|
|
88
|
-
accessToken = cfg
|
|
89
|
-
defaultCalendarId = cfg
|
|
88
|
+
accessToken = cfg['accessToken'] as string
|
|
89
|
+
defaultCalendarId = cfg['calendarId'] as string | undefined
|
|
90
90
|
|
|
91
91
|
if (!accessToken) {
|
|
92
92
|
throw new Error('Google Calendar access token is required')
|
|
@@ -135,7 +135,7 @@ export function createGoogleCalendarProvider(config: ProviderConfig): CalendarPr
|
|
|
135
135
|
return {
|
|
136
136
|
items,
|
|
137
137
|
hasMore: !!result.data.nextPageToken,
|
|
138
|
-
nextCursor: result.data.nextPageToken,
|
|
138
|
+
...(result.data.nextPageToken !== undefined && { nextCursor: result.data.nextPageToken }),
|
|
139
139
|
}
|
|
140
140
|
},
|
|
141
141
|
|
|
@@ -183,7 +183,8 @@ export function createGoogleCalendarProvider(config: ProviderConfig): CalendarPr
|
|
|
183
183
|
createRequest: {
|
|
184
184
|
requestId: `${Date.now()}-${Math.random()}`,
|
|
185
185
|
conferenceSolutionKey: {
|
|
186
|
-
type:
|
|
186
|
+
type:
|
|
187
|
+
event.conferenceData.type === 'hangoutsMeet' ? 'hangoutsMeet' : 'hangoutsMeet',
|
|
187
188
|
},
|
|
188
189
|
},
|
|
189
190
|
}
|
|
@@ -191,10 +192,13 @@ export function createGoogleCalendarProvider(config: ProviderConfig): CalendarPr
|
|
|
191
192
|
}
|
|
192
193
|
|
|
193
194
|
const params = event.conferenceData ? '?conferenceDataVersion=1' : ''
|
|
194
|
-
const result = await apiRequest<any>(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
195
|
+
const result = await apiRequest<any>(
|
|
196
|
+
`/calendars/${encodeURIComponent(calendarId)}/events${params}`,
|
|
197
|
+
{
|
|
198
|
+
method: 'POST',
|
|
199
|
+
body: JSON.stringify(body),
|
|
200
|
+
}
|
|
201
|
+
)
|
|
198
202
|
|
|
199
203
|
if (!result.ok || !result.data) {
|
|
200
204
|
throw new Error(result.error || 'Failed to create event')
|
|
@@ -332,7 +336,8 @@ export function createGoogleCalendarProvider(config: ProviderConfig): CalendarPr
|
|
|
332
336
|
if (options?.cursor) params.append('pageToken', options.cursor)
|
|
333
337
|
if (options?.timeMin) params.append('timeMin', options.timeMin.toISOString())
|
|
334
338
|
if (options?.timeMax) params.append('timeMax', options.timeMax.toISOString())
|
|
335
|
-
if (options?.singleEvents !== undefined)
|
|
339
|
+
if (options?.singleEvents !== undefined)
|
|
340
|
+
params.append('singleEvents', String(options.singleEvents))
|
|
336
341
|
if (options?.orderBy) params.append('orderBy', options.orderBy)
|
|
337
342
|
|
|
338
343
|
const result = await apiRequest<{
|
|
@@ -364,7 +369,7 @@ export function createGoogleCalendarProvider(config: ProviderConfig): CalendarPr
|
|
|
364
369
|
return {
|
|
365
370
|
items,
|
|
366
371
|
hasMore: !!result.data.nextPageToken,
|
|
367
|
-
nextCursor: result.data.nextPageToken,
|
|
372
|
+
...(result.data.nextPageToken !== undefined && { nextCursor: result.data.nextPageToken }),
|
|
368
373
|
}
|
|
369
374
|
},
|
|
370
375
|
|
|
@@ -394,10 +399,11 @@ export function createGoogleCalendarProvider(config: ProviderConfig): CalendarPr
|
|
|
394
399
|
const calendar = result.data!.calendars[calendarId]
|
|
395
400
|
return {
|
|
396
401
|
calendarId,
|
|
397
|
-
busy:
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
402
|
+
busy:
|
|
403
|
+
calendar?.busy?.map((slot) => ({
|
|
404
|
+
start: new Date(slot.start),
|
|
405
|
+
end: new Date(slot.end),
|
|
406
|
+
})) || [],
|
|
401
407
|
}
|
|
402
408
|
})
|
|
403
409
|
},
|