@tangle-network/chatgpt-agents-kit 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -112,6 +112,11 @@ export interface NativeTaskSummary extends Target {
112
112
  updatedAt?: string;
113
113
  completedAt?: string;
114
114
  }
115
+ export interface NativeTaskOptions {
116
+ contextVersion?: string;
117
+ /** One task only. Native policy validates access, availability and input-bound replay. */
118
+ model?: string;
119
+ }
115
120
  export interface NativeServices {
116
121
  list(): Promise<Array<{
117
122
  workspaceId: string;
@@ -136,9 +141,7 @@ export interface NativeServices {
136
141
  putFile?(target: Target, path: string, content: string, expectedRevision: string | null): Promise<{
137
142
  revision: string;
138
143
  }>;
139
- startTask?(target: Target, turnId: string, brief: string, options?: {
140
- contextVersion?: string;
141
- }): Promise<NativeTask>;
144
+ startTask?(target: Target, turnId: string, brief: string, options?: NativeTaskOptions): Promise<NativeTask>;
142
145
  getTask?(target: Target, turnId: string): Promise<NativeTask>;
143
146
  readResponse?(target: Target, turnId: string): Promise<NativeResponse | null>;
144
147
  /** Cancel exactly this execution; never choose the latest run in a session. */
@@ -169,6 +172,8 @@ export interface NativeBinding {
169
172
  requiredScopes: Partial<Record<Action, readonly string[]>>;
170
173
  /** Calls existing workspace/thread RBAC. Recheck live, including after awaited reads. */
171
174
  authorize(target: Target, action: Action): Promise<void>;
175
+ /** Opt in only when startTask validates and binds an explicit model to task identity. */
176
+ modelSelection?: boolean;
172
177
  services: NativeServices;
173
178
  }
174
179
  export interface NativeTool {
package/dist/src/gtm.d.ts CHANGED
@@ -12,6 +12,7 @@ export interface GtmNativeContext {
12
12
  request(path: string, init: RequestInit): Promise<Response>;
13
13
  /** Use the persisted agent-app turn path. HTTP 200 alone is NOT admission. */
14
14
  turns?: Pick<NativeServices, 'startTask' | 'getTask'>;
15
+ modelSelection?: NativeBinding['modelSelection'];
15
16
  interactions?: Pick<NativeServices, 'pendingDecisions' | 'decide'>;
16
17
  /** Native paginated discovery; absent services expose no discovery tools. */
17
18
  directory?: Pick<NativeServices, 'listThreads' | 'listTasks'>;
package/dist/src/gtm.js CHANGED
@@ -76,7 +76,7 @@ export function createGtmBinding(context) {
76
76
  };
77
77
  return {
78
78
  platformUserId: context.platformUserId, applicationUserId: context.applicationUserId,
79
- appName: 'tangle-agents-gtm', authorize: context.authorize, services,
79
+ appName: 'tangle-agents-gtm', authorize: context.authorize, services, modelSelection: context.modelSelection,
80
80
  // These are GTM's reviewed native scopes. Do NOT reinterpret Hub's `read`
81
81
  // or `workflows:write` token as these permissions; ungranted actions cannot run.
82
82
  requiredScopes: { list: read, connect: read, create: write, handoff: write, delegate: run, task: read, output: read, decisions: read, decide: run },
@@ -1,7 +1,7 @@
1
1
  export { createAgentsHandler } from './kit.ts';
2
2
  export { createGtmBinding } from './gtm.ts';
3
3
  export { AgentFailure } from './contracts.ts';
4
- export type { Action, Metadata, NativeBinding, NativeChannel, NativeFile, NativeMcpFactory, NativeServices, NativeTask, NativeResponse, NativeConnection, NativeEnvironment, OAuthResource, Principal, Target, NativeDirectoryQuery, NativeTaskQuery, NativeThreadSummary, NativeTaskSummary, } from './contracts.ts';
4
+ export type { Action, Metadata, NativeBinding, NativeChannel, NativeFile, NativeMcpFactory, NativeServices, NativeTask, NativeTaskOptions, NativeResponse, NativeConnection, NativeEnvironment, OAuthResource, Principal, Target, NativeDirectoryQuery, NativeTaskQuery, NativeThreadSummary, NativeTaskSummary, } from './contracts.ts';
5
5
  export type { GtmNativeContext } from './gtm.ts';
6
6
  export type { InspectionBinding, InspectionExposure } from './inspection.ts';
7
7
  export { createTaskEvents, TASK_EVENT } from './task-events.ts';
package/dist/src/kit.js CHANGED
@@ -225,7 +225,10 @@ async function run(action, args, binding, revalidate, signal, policy, canReadTas
225
225
  throw new PreAdmissionFailure(error);
226
226
  }
227
227
  try {
228
- const task = await s.startTask(target, args.turnId, args.prompt, args.contextVersion === undefined ? undefined : { contextVersion: args.contextVersion });
228
+ const task = await s.startTask(target, args.turnId, args.prompt, args.contextVersion === undefined && args.model === undefined ? undefined : {
229
+ ...(args.contextVersion === undefined ? {} : { contextVersion: args.contextVersion }),
230
+ ...(args.model === undefined ? {} : { model: args.model }),
231
+ });
229
232
  result = await taskReceipt(binding, target, await observe(task, policy.defaultMs), args.turnId, canReadOutput, checkOutput);
230
233
  break;
231
234
  }
@@ -467,6 +470,9 @@ export function createAgentsHandler(options) {
467
470
  _meta: { ui: { prefersBorder: true, csp: { connectDomains: [], resourceDomains: [] }, ...(options.cards.domain ? { domain: options.cards.domain } : {}) } },
468
471
  }], ...(v2 ? { resultType: 'complete' } : {}) } });
469
472
  }
473
+ const actionSchemas = { ...schemas, delegate: binding.modelSelection
474
+ ? { ...schemas.delegate, model: { ...str, optional: true, description: 'Model for this task only. The app validates availability and permissions; omission preserves its saved default. Changing model requires a new turnId.' } }
475
+ : schemas.delegate };
470
476
  const directory = directoryTools(binding, actions, revalidate);
471
477
  const executableTools = [...actions.map(action => names[action]), ...directory.map(tool => tool.name)];
472
478
  const workflows = describeAgentWorkflows(actions);
@@ -475,9 +481,9 @@ export function createAgentsHandler(options) {
475
481
  const tools = [
476
482
  { name: 'agent_profile', description: 'Stable application identity of the authenticated account.', inputSchema: { type: 'object', properties: {}, additionalProperties: false }, run: async (args) => { validate(args, {}); return { id: binding.applicationUserId, ...(binding.name ? { name: binding.name } : {}) }; } },
477
483
  { name: 'agent_capabilities', description: 'Discover actions actually supported for this identity, app and grant now.', inputSchema: { type: 'object', properties: {}, additionalProperties: false }, run: async (args) => { validate(args, {}); return { appName: binding.appName, actions: [...executableTools, ...(handoff ? [handoff.name] : [])], workflows, inspection: inspection?.tools.map(tool => tool.name) ?? [], media: ['text/plain; charset=utf-8'], compatibilityAliases: actions.includes('delegate') ? { delegate_task: names.delegate } : {}, preferredPromptTool: actions.includes('delegate') ? names.delegate : null, resultKinds: canReadOutput ? [...(binding.services.readFile ? ['files'] : []), ...(binding.services.readResponse ? ['response'] : [])] : [], execution: 'native-application', stateStore: 'native-application', taskWait: { defaultMs: waitPolicy.defaultMs, maxMs: waitPolicy.maxMs }, events: eventsEnabled ? { name: 'agent.task_updated', protocolVersion: '2026-07-28', delivery: ['webhook'], replay: false } : null }; } },
478
- ...advertisedActions.map(action => ({ name: names[action], description: descriptions[action], inputSchema: { type: 'object', properties: Object.fromEntries(Object.entries(schemas[action]).map(([key, value]) => { const { optional: _optional, ...schema } = value; return [key, schema]; })), required: Object.keys(schemas[action]).filter(key => !schemas[action][key].optional), additionalProperties: false }, run: async (args) => {
484
+ ...advertisedActions.map(action => ({ name: names[action], description: descriptions[action], inputSchema: { type: 'object', properties: Object.fromEntries(Object.entries(actionSchemas[action]).map(([key, value]) => { const { optional: _optional, ...schema } = value; return [key, schema]; })), required: Object.keys(actionSchemas[action]).filter(key => !actionSchemas[action][key].optional), additionalProperties: false }, run: async (args) => {
479
485
  try {
480
- validate(args, schemas[action]);
486
+ validate(args, actionSchemas[action]);
481
487
  }
482
488
  catch (error) {
483
489
  throw action === 'delegate' ? new PreAdmissionFailure(error) : error;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/chatgpt-agents-kit",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/tangle-network/chatgpt-plugins.git",