@ptkl/sdk 1.17.0 → 1.18.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/dist/index.0.10.js +71 -15
- package/dist/package.json +1 -1
- package/dist/v0.10/api/forge.d.ts +51 -2
- package/dist/v0.10/api/index.d.ts +2 -1
- package/dist/v0.10/api/kortex.d.ts +2 -3
- package/dist/v0.10/index.cjs.js +71 -15
- package/dist/v0.10/index.esm.js +71 -15
- package/dist/v0.10/types/component.d.ts +10 -0
- package/dist/v0.10/types/forge.d.ts +11 -0
- package/dist/v0.10/types/kortex.d.ts +9 -15
- package/dist/v0.9/types/component.d.ts +10 -0
- package/package.json +1 -1
package/dist/index.0.10.js
CHANGED
|
@@ -1628,18 +1628,51 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
1628
1628
|
return await this.client.get(`/luma/appservice/v1/forge/${ref}/services`);
|
|
1629
1629
|
}
|
|
1630
1630
|
// --- Variables ---
|
|
1631
|
+
/**
|
|
1632
|
+
* Build the variables path for a target app.
|
|
1633
|
+
*
|
|
1634
|
+
* Omitting `ref` selects the pathless self route, where the server resolves the
|
|
1635
|
+
* app from the caller's own token. That is why the self forms work in every
|
|
1636
|
+
* context an app token does, including Node, where `resolveCurrentAppUuid()`
|
|
1637
|
+
* has nothing to read.
|
|
1638
|
+
*/
|
|
1639
|
+
variablesPath(ref) {
|
|
1640
|
+
return ref
|
|
1641
|
+
? `/luma/appservice/v1/forge/${encodeURIComponent(ref)}/variables`
|
|
1642
|
+
: `/luma/appservice/v1/forge/variables`;
|
|
1643
|
+
}
|
|
1644
|
+
/**
|
|
1645
|
+
* Read variables for the current environment (`X-Project-Env`, defaults to dev).
|
|
1646
|
+
*
|
|
1647
|
+
* With no argument this returns the CALLING APP's own variables and needs no
|
|
1648
|
+
* permission at all. With a `ref` it reads that app's variables and needs
|
|
1649
|
+
* `manage forge`.
|
|
1650
|
+
*
|
|
1651
|
+
* @param ref App uuid, name or tag. Omit for the current app.
|
|
1652
|
+
*
|
|
1653
|
+
* @example
|
|
1654
|
+
* const mine = await platform.forge().getVariables()
|
|
1655
|
+
* const other = await platform.forge().getVariables('storefront')
|
|
1656
|
+
*/
|
|
1631
1657
|
async getVariables(ref) {
|
|
1632
|
-
return await this.client.get(
|
|
1658
|
+
return await this.client.get(this.variablesPath(ref));
|
|
1633
1659
|
}
|
|
1634
|
-
async updateVariables(
|
|
1635
|
-
|
|
1660
|
+
async updateVariables(a, b) {
|
|
1661
|
+
const [ref, variables] = typeof a === 'string'
|
|
1662
|
+
? [a, b]
|
|
1663
|
+
: [undefined, a];
|
|
1664
|
+
return await this.client.patch(this.variablesPath(ref), variables);
|
|
1636
1665
|
}
|
|
1637
|
-
async addVariable(
|
|
1666
|
+
async addVariable(a, b, c) {
|
|
1638
1667
|
var _a;
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1668
|
+
// Arity, not `c !== undefined` — otherwise addVariable('ref', 'KEY', undefined)
|
|
1669
|
+
// is read as the two-argument self form and writes a variable named "ref".
|
|
1670
|
+
const [ref, key, value] = arguments.length >= 3
|
|
1671
|
+
? [a, b, c]
|
|
1672
|
+
: [undefined, a, b];
|
|
1673
|
+
const path = this.variablesPath(ref);
|
|
1674
|
+
const resp = await this.client.get(path);
|
|
1675
|
+
return await this.client.patch(path, { ...((_a = resp.data) !== null && _a !== void 0 ? _a : {}), [key]: value });
|
|
1643
1676
|
}
|
|
1644
1677
|
// --- Service execution (forge-runtime) ---
|
|
1645
1678
|
/**
|
|
@@ -1795,17 +1828,40 @@ var ProtokolSDK010 = (function (exports, axios) {
|
|
|
1795
1828
|
async injectMessage(conversationUUID, data) {
|
|
1796
1829
|
return await this.client.post(`${BASE$1}/conversations/${conversationUUID}/messages/inject`, data);
|
|
1797
1830
|
}
|
|
1831
|
+
// ── Stateless chat ──
|
|
1832
|
+
// Stateless completion — no conversation is created and nothing is
|
|
1833
|
+
// persisted. The caller owns the message list.
|
|
1834
|
+
//
|
|
1835
|
+
// Returns the raw SSE body as a string: events separated by blank lines,
|
|
1836
|
+
// each `event: <name>` + `data: <json>`. Tool calls arrive in
|
|
1837
|
+
// message_complete for client-side execution; post the results back as
|
|
1838
|
+
// messages with role 'tool' and the matching tool_call_id.
|
|
1839
|
+
//
|
|
1840
|
+
// NOT typed as a stream, deliberately. This SDK is executed inside
|
|
1841
|
+
// isolated-vm sandboxes (the eval server runs the bundle in-isolate and
|
|
1842
|
+
// proxies HTTP through an adapter), and every value crossing that boundary
|
|
1843
|
+
// is structure-cloned. A Node Readable carries internal callbacks and dies
|
|
1844
|
+
// there with "could not be cloned" — an error that points nowhere near the
|
|
1845
|
+
// method that caused it. Buffering keeps this binding usable everywhere.
|
|
1846
|
+
//
|
|
1847
|
+
// A consumer that genuinely needs incremental delivery should drive the
|
|
1848
|
+
// endpoint directly rather than through the SDK, as the kortex CLI does.
|
|
1849
|
+
//
|
|
1850
|
+
// Constraints enforced server-side: agent_uuid is required, the last
|
|
1851
|
+
// message must have role 'user', 'context' or 'tool', and no message
|
|
1852
|
+
// content may exceed 32000 bytes.
|
|
1853
|
+
async chat(data) {
|
|
1854
|
+
return await this.client.post(`${BASE$1}/chat`, data, {
|
|
1855
|
+
responseType: 'text',
|
|
1856
|
+
// Keep the SSE body intact — the default transform attempts JSON.parse.
|
|
1857
|
+
transformResponse: [(body) => body],
|
|
1858
|
+
timeout: 120000,
|
|
1859
|
+
});
|
|
1860
|
+
}
|
|
1798
1861
|
// ── OCR ──
|
|
1799
1862
|
async ocr(data) {
|
|
1800
1863
|
return await this.client.post(`${BASE$1}/ocr`, data, { timeout: 120000 });
|
|
1801
1864
|
}
|
|
1802
|
-
// ── Workflow ──
|
|
1803
|
-
async workflowComplete(data) {
|
|
1804
|
-
return await this.client.post(`${BASE$1}/workflow/complete`, data);
|
|
1805
|
-
}
|
|
1806
|
-
async workflowOcr(data) {
|
|
1807
|
-
return await this.client.post(`${BASE$1}/workflow/ocr`, data, { timeout: 120000 });
|
|
1808
|
-
}
|
|
1809
1865
|
// ── User Access ──
|
|
1810
1866
|
async createUserAccess(data) {
|
|
1811
1867
|
return await this.client.post(`${BASE$1}/user-access`, data);
|
package/dist/package.json
CHANGED
|
@@ -1,12 +1,61 @@
|
|
|
1
1
|
import PlatformBaseClient from "./platformBaseClient";
|
|
2
|
+
import type { ForgeVariables } from "../types/forge";
|
|
2
3
|
export default class Forge extends PlatformBaseClient {
|
|
3
4
|
bundleUpload(buffer: Buffer): Promise<any>;
|
|
4
5
|
getWorkspaceApps(): Promise<any>;
|
|
5
6
|
removeVersion(ref: string, version: string): Promise<any>;
|
|
6
7
|
list(): Promise<any>;
|
|
7
8
|
listServices(ref: string): Promise<any>;
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
/**
|
|
10
|
+
* Build the variables path for a target app.
|
|
11
|
+
*
|
|
12
|
+
* Omitting `ref` selects the pathless self route, where the server resolves the
|
|
13
|
+
* app from the caller's own token. That is why the self forms work in every
|
|
14
|
+
* context an app token does, including Node, where `resolveCurrentAppUuid()`
|
|
15
|
+
* has nothing to read.
|
|
16
|
+
*/
|
|
17
|
+
private variablesPath;
|
|
18
|
+
/**
|
|
19
|
+
* Read variables for the current environment (`X-Project-Env`, defaults to dev).
|
|
20
|
+
*
|
|
21
|
+
* With no argument this returns the CALLING APP's own variables and needs no
|
|
22
|
+
* permission at all. With a `ref` it reads that app's variables and needs
|
|
23
|
+
* `manage forge`.
|
|
24
|
+
*
|
|
25
|
+
* @param ref App uuid, name or tag. Omit for the current app.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* const mine = await platform.forge().getVariables()
|
|
29
|
+
* const other = await platform.forge().getVariables('storefront')
|
|
30
|
+
*/
|
|
31
|
+
getVariables(ref?: string): Promise<any>;
|
|
32
|
+
/**
|
|
33
|
+
* Replace the variable set for the current environment.
|
|
34
|
+
*
|
|
35
|
+
* This REPLACES the whole set for that environment — keys absent from
|
|
36
|
+
* `variables` are removed. The other environment is left untouched.
|
|
37
|
+
*
|
|
38
|
+
* The self form needs `manage_variables forge`, which only ever writes the
|
|
39
|
+
* calling app. Targeting another app by `ref` needs `manage forge`.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* await platform.forge().updateVariables({ WEBHOOK_URL: '...' })
|
|
43
|
+
* await platform.forge().updateVariables('storefront', { WEBHOOK_URL: '...' })
|
|
44
|
+
*/
|
|
45
|
+
updateVariables(variables: ForgeVariables): Promise<any>;
|
|
46
|
+
updateVariables(ref: string, variables: ForgeVariables): Promise<any>;
|
|
47
|
+
/**
|
|
48
|
+
* Set a single variable, preserving the rest.
|
|
49
|
+
*
|
|
50
|
+
* A read-modify-write over a replace-everything PATCH, so concurrent writers
|
|
51
|
+
* can lose each other's updates. Prefer `updateVariables` when setting more
|
|
52
|
+
* than one key.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* await platform.forge().addVariable('WEBHOOK_URL', '...')
|
|
56
|
+
* await platform.forge().addVariable('storefront', 'WEBHOOK_URL', '...')
|
|
57
|
+
*/
|
|
58
|
+
addVariable(key: string, value: any): Promise<any>;
|
|
10
59
|
addVariable(ref: string, key: string, value: any): Promise<any>;
|
|
11
60
|
/**
|
|
12
61
|
* Run a Forge service: `runService(target, body?, { query?, headers? })`.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export type { PlatformFunctions, PlatformFunction, FunctionInput, FunctionOutput, FunctionCallParams, ComponentModels, ComponentFunctions, ComponentModel, ComponentFunctionInput, ComponentFunctionOutput, } from '../types/functions';
|
|
2
2
|
export type { Settings, SettingsField, FieldRoles, FieldConstraints, Context, Preset, PresetContext, Filters, Extension, Policy, SetupData, Model, } from '../types/component';
|
|
3
3
|
export type { WorkflowModel, WorkflowSettings, WorkflowNode, WorkflowNodeConnection, WorkflowCreatePayload, WorkflowUpdatePayload, WorkflowListResponse, } from '../types/workflow';
|
|
4
|
-
export type { PagedResponse as KortexPagedResponse, PaginationParams as KortexPaginationParams, RAGConfig, LLMSettings, Agent, AgentCreatePayload, AgentUpdatePayload, ChunkingStrategy, KnowledgeBase, KnowledgeBaseCreatePayload, KnowledgeBaseUpdatePayload, Document as KortexDocument, Participant, TokenUsage, ToolCall, RAGSource, Message as KortexMessage, Conversation, ConversationCreatePayload, ConversationUpdatePayload, ParticipantAddPayload, ToolResultPayload, PageContext, SendMessagePayload, InjectMessagePayload, OCRPayload, OCRResult, UserAccess, UserAccessCreatePayload, UserAccessUpdatePayload, TopUpPayload, UserMonthlyUsage, UserUsageBreakdown, MyAccess, AggregatedUsage, Tier,
|
|
4
|
+
export type { PagedResponse as KortexPagedResponse, PaginationParams as KortexPaginationParams, RAGConfig, LLMSettings, Agent, AgentCreatePayload, AgentUpdatePayload, ChunkingStrategy, KnowledgeBase, KnowledgeBaseCreatePayload, KnowledgeBaseUpdatePayload, Document as KortexDocument, Participant, TokenUsage, ToolCall, RAGSource, Message as KortexMessage, Conversation, ConversationCreatePayload, ConversationUpdatePayload, ParticipantAddPayload, ToolResultPayload, PageContext, SendMessagePayload, InjectMessagePayload, OCRPayload, OCRResult, UserAccess, UserAccessCreatePayload, UserAccessUpdatePayload, TopUpPayload, UserMonthlyUsage, UserUsageBreakdown, MyAccess, AggregatedUsage, Tier, KortexChatRole, KortexChatMessage, KortexChatPayload, } from '../types/kortex';
|
|
5
5
|
export type { TimberActor, TimberActorType, TimberChanges, TimberEntry, TimberLevel, TimberQueryParams, TimberQueryResponse, TimberSource, TimberUsage, TimberWritePayload, TimberLogPayload, } from '../types/timber';
|
|
6
6
|
export type { SatelliteAuthConfig, SatelliteAuthType, SatelliteCommandExecutePayload, SatelliteCommandExecuteResponse, SatelliteCreatePayload, SatelliteDeployPayload, SatelliteEnv, SatelliteJsonRpcCommand, SatelliteLocaleText, SatelliteLogsParams, SatellitePermission, SatellitePermissionExport, SatelliteSchemaPayload, SatelliteSchemaVersion, SatelliteTemplate, SatelliteTemplatePayload, SatelliteWorkflowNode, SatelliteWorkflowNodeField, } from '../types/satellites';
|
|
7
7
|
export { default as Component } from './component';
|
|
@@ -17,6 +17,7 @@ export { default as Sandbox } from './sandbox';
|
|
|
17
17
|
export { default as System } from './system';
|
|
18
18
|
export { default as Workflow } from './workflow';
|
|
19
19
|
export { default as Forge } from './forge';
|
|
20
|
+
export type { ForgeVariables } from '../types/forge';
|
|
20
21
|
export { default as Kortex } from './kortex';
|
|
21
22
|
export { default as Project } from './project';
|
|
22
23
|
export { default as Config } from './config';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AxiosResponse } from 'axios';
|
|
2
2
|
import PlatformBaseClient from "./platformBaseClient";
|
|
3
|
-
import { PagedResponse, PaginationParams, Agent, AgentCreatePayload, AgentUpdatePayload, KnowledgeBase, KnowledgeBaseCreatePayload, KnowledgeBaseUpdatePayload, Document, Conversation, ConversationCreatePayload, ConversationUpdatePayload, ParticipantAddPayload, Message, SendMessagePayload, InjectMessagePayload, OCRPayload, OCRResult, UserAccess, UserAccessCreatePayload, UserAccessUpdatePayload, UserMonthlyUsage, UserUsageBreakdown, MyAccess, AggregatedUsage, Tier, KnowledgeBaseSearchPayload, KnowledgeBaseSearchResult,
|
|
3
|
+
import { PagedResponse, PaginationParams, Agent, AgentCreatePayload, AgentUpdatePayload, KnowledgeBase, KnowledgeBaseCreatePayload, KnowledgeBaseUpdatePayload, Document, Conversation, ConversationCreatePayload, ConversationUpdatePayload, ParticipantAddPayload, Message, SendMessagePayload, InjectMessagePayload, OCRPayload, OCRResult, UserAccess, UserAccessCreatePayload, UserAccessUpdatePayload, UserMonthlyUsage, UserUsageBreakdown, MyAccess, AggregatedUsage, Tier, KnowledgeBaseSearchPayload, KnowledgeBaseSearchResult, KortexChatPayload } from '../types/kortex';
|
|
4
4
|
export default class Kortex extends PlatformBaseClient {
|
|
5
5
|
createAgent(data: AgentCreatePayload): Promise<AxiosResponse<Agent>>;
|
|
6
6
|
listAgents(params?: PaginationParams): Promise<AxiosResponse<PagedResponse<Agent>>>;
|
|
@@ -35,9 +35,8 @@ export default class Kortex extends PlatformBaseClient {
|
|
|
35
35
|
streamMessage(conversationUUID: string, data: SendMessagePayload): Promise<AxiosResponse<ReadableStream>>;
|
|
36
36
|
listMessages(conversationUUID: string, params?: PaginationParams): Promise<AxiosResponse<PagedResponse<Message>>>;
|
|
37
37
|
injectMessage(conversationUUID: string, data: InjectMessagePayload): Promise<AxiosResponse<Message>>;
|
|
38
|
+
chat(data: KortexChatPayload): Promise<AxiosResponse<string>>;
|
|
38
39
|
ocr(data: OCRPayload): Promise<AxiosResponse<OCRResult>>;
|
|
39
|
-
workflowComplete(data: KortexWorkflowPayload): Promise<AxiosResponse<KortexWorkflowResult>>;
|
|
40
|
-
workflowOcr(data: OCRPayload): Promise<AxiosResponse<OCRResult>>;
|
|
41
40
|
createUserAccess(data: UserAccessCreatePayload): Promise<AxiosResponse<UserAccess>>;
|
|
42
41
|
listUserAccess(params?: PaginationParams): Promise<AxiosResponse<PagedResponse<UserAccess>>>;
|
|
43
42
|
getUserAccess(uuid: string): Promise<AxiosResponse<UserAccess>>;
|
package/dist/v0.10/index.cjs.js
CHANGED
|
@@ -20594,18 +20594,51 @@ class Forge extends PlatformBaseClient {
|
|
|
20594
20594
|
return await this.client.get(`/luma/appservice/v1/forge/${ref}/services`);
|
|
20595
20595
|
}
|
|
20596
20596
|
// --- Variables ---
|
|
20597
|
+
/**
|
|
20598
|
+
* Build the variables path for a target app.
|
|
20599
|
+
*
|
|
20600
|
+
* Omitting `ref` selects the pathless self route, where the server resolves the
|
|
20601
|
+
* app from the caller's own token. That is why the self forms work in every
|
|
20602
|
+
* context an app token does, including Node, where `resolveCurrentAppUuid()`
|
|
20603
|
+
* has nothing to read.
|
|
20604
|
+
*/
|
|
20605
|
+
variablesPath(ref) {
|
|
20606
|
+
return ref
|
|
20607
|
+
? `/luma/appservice/v1/forge/${encodeURIComponent(ref)}/variables`
|
|
20608
|
+
: `/luma/appservice/v1/forge/variables`;
|
|
20609
|
+
}
|
|
20610
|
+
/**
|
|
20611
|
+
* Read variables for the current environment (`X-Project-Env`, defaults to dev).
|
|
20612
|
+
*
|
|
20613
|
+
* With no argument this returns the CALLING APP's own variables and needs no
|
|
20614
|
+
* permission at all. With a `ref` it reads that app's variables and needs
|
|
20615
|
+
* `manage forge`.
|
|
20616
|
+
*
|
|
20617
|
+
* @param ref App uuid, name or tag. Omit for the current app.
|
|
20618
|
+
*
|
|
20619
|
+
* @example
|
|
20620
|
+
* const mine = await platform.forge().getVariables()
|
|
20621
|
+
* const other = await platform.forge().getVariables('storefront')
|
|
20622
|
+
*/
|
|
20597
20623
|
async getVariables(ref) {
|
|
20598
|
-
return await this.client.get(
|
|
20624
|
+
return await this.client.get(this.variablesPath(ref));
|
|
20599
20625
|
}
|
|
20600
|
-
async updateVariables(
|
|
20601
|
-
|
|
20626
|
+
async updateVariables(a, b) {
|
|
20627
|
+
const [ref, variables] = typeof a === 'string'
|
|
20628
|
+
? [a, b]
|
|
20629
|
+
: [undefined, a];
|
|
20630
|
+
return await this.client.patch(this.variablesPath(ref), variables);
|
|
20602
20631
|
}
|
|
20603
|
-
async addVariable(
|
|
20632
|
+
async addVariable(a, b, c) {
|
|
20604
20633
|
var _a;
|
|
20605
|
-
|
|
20606
|
-
|
|
20607
|
-
|
|
20608
|
-
|
|
20634
|
+
// Arity, not `c !== undefined` — otherwise addVariable('ref', 'KEY', undefined)
|
|
20635
|
+
// is read as the two-argument self form and writes a variable named "ref".
|
|
20636
|
+
const [ref, key, value] = arguments.length >= 3
|
|
20637
|
+
? [a, b, c]
|
|
20638
|
+
: [undefined, a, b];
|
|
20639
|
+
const path = this.variablesPath(ref);
|
|
20640
|
+
const resp = await this.client.get(path);
|
|
20641
|
+
return await this.client.patch(path, { ...((_a = resp.data) !== null && _a !== void 0 ? _a : {}), [key]: value });
|
|
20609
20642
|
}
|
|
20610
20643
|
// --- Service execution (forge-runtime) ---
|
|
20611
20644
|
/**
|
|
@@ -20761,17 +20794,40 @@ class Kortex extends PlatformBaseClient {
|
|
|
20761
20794
|
async injectMessage(conversationUUID, data) {
|
|
20762
20795
|
return await this.client.post(`${BASE$1}/conversations/${conversationUUID}/messages/inject`, data);
|
|
20763
20796
|
}
|
|
20797
|
+
// ── Stateless chat ──
|
|
20798
|
+
// Stateless completion — no conversation is created and nothing is
|
|
20799
|
+
// persisted. The caller owns the message list.
|
|
20800
|
+
//
|
|
20801
|
+
// Returns the raw SSE body as a string: events separated by blank lines,
|
|
20802
|
+
// each `event: <name>` + `data: <json>`. Tool calls arrive in
|
|
20803
|
+
// message_complete for client-side execution; post the results back as
|
|
20804
|
+
// messages with role 'tool' and the matching tool_call_id.
|
|
20805
|
+
//
|
|
20806
|
+
// NOT typed as a stream, deliberately. This SDK is executed inside
|
|
20807
|
+
// isolated-vm sandboxes (the eval server runs the bundle in-isolate and
|
|
20808
|
+
// proxies HTTP through an adapter), and every value crossing that boundary
|
|
20809
|
+
// is structure-cloned. A Node Readable carries internal callbacks and dies
|
|
20810
|
+
// there with "could not be cloned" — an error that points nowhere near the
|
|
20811
|
+
// method that caused it. Buffering keeps this binding usable everywhere.
|
|
20812
|
+
//
|
|
20813
|
+
// A consumer that genuinely needs incremental delivery should drive the
|
|
20814
|
+
// endpoint directly rather than through the SDK, as the kortex CLI does.
|
|
20815
|
+
//
|
|
20816
|
+
// Constraints enforced server-side: agent_uuid is required, the last
|
|
20817
|
+
// message must have role 'user', 'context' or 'tool', and no message
|
|
20818
|
+
// content may exceed 32000 bytes.
|
|
20819
|
+
async chat(data) {
|
|
20820
|
+
return await this.client.post(`${BASE$1}/chat`, data, {
|
|
20821
|
+
responseType: 'text',
|
|
20822
|
+
// Keep the SSE body intact — the default transform attempts JSON.parse.
|
|
20823
|
+
transformResponse: [(body) => body],
|
|
20824
|
+
timeout: 120000,
|
|
20825
|
+
});
|
|
20826
|
+
}
|
|
20764
20827
|
// ── OCR ──
|
|
20765
20828
|
async ocr(data) {
|
|
20766
20829
|
return await this.client.post(`${BASE$1}/ocr`, data, { timeout: 120000 });
|
|
20767
20830
|
}
|
|
20768
|
-
// ── Workflow ──
|
|
20769
|
-
async workflowComplete(data) {
|
|
20770
|
-
return await this.client.post(`${BASE$1}/workflow/complete`, data);
|
|
20771
|
-
}
|
|
20772
|
-
async workflowOcr(data) {
|
|
20773
|
-
return await this.client.post(`${BASE$1}/workflow/ocr`, data, { timeout: 120000 });
|
|
20774
|
-
}
|
|
20775
20831
|
// ── User Access ──
|
|
20776
20832
|
async createUserAccess(data) {
|
|
20777
20833
|
return await this.client.post(`${BASE$1}/user-access`, data);
|
package/dist/v0.10/index.esm.js
CHANGED
|
@@ -1627,18 +1627,51 @@ class Forge extends PlatformBaseClient {
|
|
|
1627
1627
|
return await this.client.get(`/luma/appservice/v1/forge/${ref}/services`);
|
|
1628
1628
|
}
|
|
1629
1629
|
// --- Variables ---
|
|
1630
|
+
/**
|
|
1631
|
+
* Build the variables path for a target app.
|
|
1632
|
+
*
|
|
1633
|
+
* Omitting `ref` selects the pathless self route, where the server resolves the
|
|
1634
|
+
* app from the caller's own token. That is why the self forms work in every
|
|
1635
|
+
* context an app token does, including Node, where `resolveCurrentAppUuid()`
|
|
1636
|
+
* has nothing to read.
|
|
1637
|
+
*/
|
|
1638
|
+
variablesPath(ref) {
|
|
1639
|
+
return ref
|
|
1640
|
+
? `/luma/appservice/v1/forge/${encodeURIComponent(ref)}/variables`
|
|
1641
|
+
: `/luma/appservice/v1/forge/variables`;
|
|
1642
|
+
}
|
|
1643
|
+
/**
|
|
1644
|
+
* Read variables for the current environment (`X-Project-Env`, defaults to dev).
|
|
1645
|
+
*
|
|
1646
|
+
* With no argument this returns the CALLING APP's own variables and needs no
|
|
1647
|
+
* permission at all. With a `ref` it reads that app's variables and needs
|
|
1648
|
+
* `manage forge`.
|
|
1649
|
+
*
|
|
1650
|
+
* @param ref App uuid, name or tag. Omit for the current app.
|
|
1651
|
+
*
|
|
1652
|
+
* @example
|
|
1653
|
+
* const mine = await platform.forge().getVariables()
|
|
1654
|
+
* const other = await platform.forge().getVariables('storefront')
|
|
1655
|
+
*/
|
|
1630
1656
|
async getVariables(ref) {
|
|
1631
|
-
return await this.client.get(
|
|
1657
|
+
return await this.client.get(this.variablesPath(ref));
|
|
1632
1658
|
}
|
|
1633
|
-
async updateVariables(
|
|
1634
|
-
|
|
1659
|
+
async updateVariables(a, b) {
|
|
1660
|
+
const [ref, variables] = typeof a === 'string'
|
|
1661
|
+
? [a, b]
|
|
1662
|
+
: [undefined, a];
|
|
1663
|
+
return await this.client.patch(this.variablesPath(ref), variables);
|
|
1635
1664
|
}
|
|
1636
|
-
async addVariable(
|
|
1665
|
+
async addVariable(a, b, c) {
|
|
1637
1666
|
var _a;
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1667
|
+
// Arity, not `c !== undefined` — otherwise addVariable('ref', 'KEY', undefined)
|
|
1668
|
+
// is read as the two-argument self form and writes a variable named "ref".
|
|
1669
|
+
const [ref, key, value] = arguments.length >= 3
|
|
1670
|
+
? [a, b, c]
|
|
1671
|
+
: [undefined, a, b];
|
|
1672
|
+
const path = this.variablesPath(ref);
|
|
1673
|
+
const resp = await this.client.get(path);
|
|
1674
|
+
return await this.client.patch(path, { ...((_a = resp.data) !== null && _a !== void 0 ? _a : {}), [key]: value });
|
|
1642
1675
|
}
|
|
1643
1676
|
// --- Service execution (forge-runtime) ---
|
|
1644
1677
|
/**
|
|
@@ -1794,17 +1827,40 @@ class Kortex extends PlatformBaseClient {
|
|
|
1794
1827
|
async injectMessage(conversationUUID, data) {
|
|
1795
1828
|
return await this.client.post(`${BASE$1}/conversations/${conversationUUID}/messages/inject`, data);
|
|
1796
1829
|
}
|
|
1830
|
+
// ── Stateless chat ──
|
|
1831
|
+
// Stateless completion — no conversation is created and nothing is
|
|
1832
|
+
// persisted. The caller owns the message list.
|
|
1833
|
+
//
|
|
1834
|
+
// Returns the raw SSE body as a string: events separated by blank lines,
|
|
1835
|
+
// each `event: <name>` + `data: <json>`. Tool calls arrive in
|
|
1836
|
+
// message_complete for client-side execution; post the results back as
|
|
1837
|
+
// messages with role 'tool' and the matching tool_call_id.
|
|
1838
|
+
//
|
|
1839
|
+
// NOT typed as a stream, deliberately. This SDK is executed inside
|
|
1840
|
+
// isolated-vm sandboxes (the eval server runs the bundle in-isolate and
|
|
1841
|
+
// proxies HTTP through an adapter), and every value crossing that boundary
|
|
1842
|
+
// is structure-cloned. A Node Readable carries internal callbacks and dies
|
|
1843
|
+
// there with "could not be cloned" — an error that points nowhere near the
|
|
1844
|
+
// method that caused it. Buffering keeps this binding usable everywhere.
|
|
1845
|
+
//
|
|
1846
|
+
// A consumer that genuinely needs incremental delivery should drive the
|
|
1847
|
+
// endpoint directly rather than through the SDK, as the kortex CLI does.
|
|
1848
|
+
//
|
|
1849
|
+
// Constraints enforced server-side: agent_uuid is required, the last
|
|
1850
|
+
// message must have role 'user', 'context' or 'tool', and no message
|
|
1851
|
+
// content may exceed 32000 bytes.
|
|
1852
|
+
async chat(data) {
|
|
1853
|
+
return await this.client.post(`${BASE$1}/chat`, data, {
|
|
1854
|
+
responseType: 'text',
|
|
1855
|
+
// Keep the SSE body intact — the default transform attempts JSON.parse.
|
|
1856
|
+
transformResponse: [(body) => body],
|
|
1857
|
+
timeout: 120000,
|
|
1858
|
+
});
|
|
1859
|
+
}
|
|
1797
1860
|
// ── OCR ──
|
|
1798
1861
|
async ocr(data) {
|
|
1799
1862
|
return await this.client.post(`${BASE$1}/ocr`, data, { timeout: 120000 });
|
|
1800
1863
|
}
|
|
1801
|
-
// ── Workflow ──
|
|
1802
|
-
async workflowComplete(data) {
|
|
1803
|
-
return await this.client.post(`${BASE$1}/workflow/complete`, data);
|
|
1804
|
-
}
|
|
1805
|
-
async workflowOcr(data) {
|
|
1806
|
-
return await this.client.post(`${BASE$1}/workflow/ocr`, data, { timeout: 120000 });
|
|
1807
|
-
}
|
|
1808
1864
|
// ── User Access ──
|
|
1809
1865
|
async createUserAccess(data) {
|
|
1810
1866
|
return await this.client.post(`${BASE$1}/user-access`, data);
|
|
@@ -251,10 +251,20 @@ type FieldConstraints = {
|
|
|
251
251
|
unique?: boolean;
|
|
252
252
|
placeholder?: string;
|
|
253
253
|
default?: string;
|
|
254
|
+
/** Bounds the *length* of a string value (input/text, password, ...). */
|
|
254
255
|
length?: {
|
|
255
256
|
min?: number | null;
|
|
256
257
|
max?: number | null;
|
|
257
258
|
};
|
|
259
|
+
/**
|
|
260
|
+
* Bounds the *value* of a numeric field (input/number). Inclusive on both
|
|
261
|
+
* ends. Prefer this over `length` for numbers — `length` is only still read
|
|
262
|
+
* as a fallback for fields authored before `range` existed.
|
|
263
|
+
*/
|
|
264
|
+
range?: {
|
|
265
|
+
min?: number | null;
|
|
266
|
+
max?: number | null;
|
|
267
|
+
};
|
|
258
268
|
not_allowed_words?: string;
|
|
259
269
|
regex?: string;
|
|
260
270
|
date?: {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A Forge app's variables for a single environment: a flat, JSON-serialisable
|
|
3
|
+
* key/value map.
|
|
4
|
+
*
|
|
5
|
+
* Each app holds two independent sets, `dev` and `live`. Which one an API call
|
|
6
|
+
* reads or writes is selected by the `X-Project-Env` header, not by this type.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* const vars: ForgeVariables = { WEBHOOK_URL: 'https://example.com/hook', MAX_RETRIES: 3 }
|
|
10
|
+
*/
|
|
11
|
+
export type ForgeVariables = Record<string, any>;
|
|
@@ -288,22 +288,16 @@ type KnowledgeBaseSearchChunk = {
|
|
|
288
288
|
type KnowledgeBaseSearchResult = {
|
|
289
289
|
chunks: KnowledgeBaseSearchChunk[];
|
|
290
290
|
};
|
|
291
|
-
type
|
|
292
|
-
|
|
291
|
+
type KortexChatRole = 'user' | 'assistant' | 'context' | 'tool';
|
|
292
|
+
type KortexChatMessage = {
|
|
293
|
+
role: KortexChatRole;
|
|
293
294
|
content: string;
|
|
295
|
+
tool_calls?: ToolCall[];
|
|
296
|
+
tool_call_id?: string;
|
|
294
297
|
};
|
|
295
|
-
type
|
|
296
|
-
agent_uuid
|
|
297
|
-
|
|
298
|
-
response_format?: string;
|
|
299
|
-
messages: KortexWorkflowMessage[];
|
|
300
|
-
stream?: boolean;
|
|
301
|
-
temperature?: number;
|
|
302
|
-
max_tokens?: number;
|
|
298
|
+
type KortexChatPayload = {
|
|
299
|
+
agent_uuid: string;
|
|
300
|
+
messages: KortexChatMessage[];
|
|
303
301
|
tools?: Record<string, any>[];
|
|
304
302
|
};
|
|
305
|
-
|
|
306
|
-
content: string;
|
|
307
|
-
usage: TokenUsage;
|
|
308
|
-
};
|
|
309
|
-
export { PagedResponse, PaginationParams, RAGConfig, LLMSettings, Agent, AgentCreatePayload, AgentUpdatePayload, ChunkingStrategy, KnowledgeBase, KnowledgeBaseCreatePayload, KnowledgeBaseUpdatePayload, Document, Participant, TokenUsage, ToolCall, RAGSource, Message, Conversation, ConversationCreatePayload, ConversationUpdatePayload, ParticipantAddPayload, ToolResultApproval, ToolResultPayload, PageContext, SendMessagePayload, InjectMessagePayload, OCRPayload, OCRResult, UserAccess, UserAccessCreatePayload, UserAccessUpdatePayload, TopUpPayload, UserMonthlyUsage, UserUsageBreakdown, MyAccess, AggregatedUsage, Tier, KnowledgeBaseSearchPayload, KnowledgeBaseSearchChunk, KnowledgeBaseSearchResult, KortexWorkflowMessage, KortexWorkflowPayload, KortexWorkflowResult, };
|
|
303
|
+
export { PagedResponse, PaginationParams, RAGConfig, LLMSettings, Agent, AgentCreatePayload, AgentUpdatePayload, ChunkingStrategy, KnowledgeBase, KnowledgeBaseCreatePayload, KnowledgeBaseUpdatePayload, Document, Participant, TokenUsage, ToolCall, RAGSource, Message, Conversation, ConversationCreatePayload, ConversationUpdatePayload, ParticipantAddPayload, ToolResultApproval, ToolResultPayload, PageContext, SendMessagePayload, InjectMessagePayload, OCRPayload, OCRResult, UserAccess, UserAccessCreatePayload, UserAccessUpdatePayload, TopUpPayload, UserMonthlyUsage, UserUsageBreakdown, MyAccess, AggregatedUsage, Tier, KnowledgeBaseSearchPayload, KnowledgeBaseSearchChunk, KnowledgeBaseSearchResult, KortexChatRole, KortexChatMessage, KortexChatPayload, };
|
|
@@ -221,10 +221,20 @@ type FieldConstraints = {
|
|
|
221
221
|
unique?: boolean;
|
|
222
222
|
placeholder?: string;
|
|
223
223
|
default?: string;
|
|
224
|
+
/** Bounds the *length* of a string value (input/text, password, ...). */
|
|
224
225
|
length?: {
|
|
225
226
|
min?: number | null;
|
|
226
227
|
max?: number | null;
|
|
227
228
|
};
|
|
229
|
+
/**
|
|
230
|
+
* Bounds the *value* of a numeric field (input/number). Inclusive on both
|
|
231
|
+
* ends. Prefer this over `length` for numbers — `length` is only still read
|
|
232
|
+
* as a fallback for fields authored before `range` existed.
|
|
233
|
+
*/
|
|
234
|
+
range?: {
|
|
235
|
+
min?: number | null;
|
|
236
|
+
max?: number | null;
|
|
237
|
+
};
|
|
228
238
|
not_allowed_words?: string;
|
|
229
239
|
regex?: string;
|
|
230
240
|
date?: {
|