@cadenya/cadenya 1.4.0 → 1.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cadenya/cadenya",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "description": "The official TypeScript SDK for the Cadenya API",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
package/src/client.ts CHANGED
@@ -85,7 +85,7 @@ export class Cadenya {
85
85
  authHeader: () => ({ Authorization: `Bearer ${apiKey}` }),
86
86
  maxRetries: options.maxRetries ?? 0,
87
87
  timeout: options.timeout,
88
- defaultHeaders: { ...nodeUserAgent('cadenya-typescript/1.3.0 (api 1.0)'), ...options.defaultHeaders },
88
+ defaultHeaders: { ...nodeUserAgent('cadenya-typescript/1.5.0 (api 1.0)'), ...options.defaultHeaders },
89
89
  fetch: options.fetch,
90
90
  logger: options.logger,
91
91
  logLevel: options.logLevel,
@@ -141,7 +141,7 @@ export class WidgetSessions {
141
141
  *
142
142
  * @example
143
143
  * ```ts
144
- * const widgetSession = await client.widgetSessions.create({ spec: { widgetId: 'sample' } });
144
+ * const widgetSession = await client.widgetSessions.create({ spec: { subject: { id: 'sample' }, tenant: { id: 'sample' }, widgetId: 'sample' } });
145
145
  * ```
146
146
  */
147
147
  create(params: WidgetSessionCreateParams, options?: RequestOptions): APIPromise<WidgetSession> {
package/src/types.ts CHANGED
@@ -3516,6 +3516,10 @@ export interface SetToolCallContentRequest_TextBlock {
3516
3516
  text: string;
3517
3517
  }
3518
3518
 
3519
+ export type StatusDetails =
3520
+ | WidgetSessionErrorInfo
3521
+ | GoogleProtobufAny;
3522
+
3519
3523
  /**
3520
3524
  * The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
3521
3525
  */
@@ -3531,7 +3535,7 @@ export interface Status {
3531
3535
  /**
3532
3536
  * A list of messages that carry the error details. There is a common set of message types for APIs to use.
3533
3537
  */
3534
- details?: Array<GoogleProtobufAny>;
3538
+ details?: Array<StatusDetails>;
3535
3539
  }
3536
3540
 
3537
3541
  export interface SubAgentSpawned {
@@ -4970,8 +4974,9 @@ export type WidgetSessionState = 'STATE_UNSPECIFIED' | 'STATE_ACTIVE' | 'STATE_E
4970
4974
  * a widget, minted server-to-server by the customer's backend. The session
4971
4975
  * carries all customer-asserted context — tenant, subject, labels, secrets —
4972
4976
  * and every conversation (objective) created through the widget inherits it.
4973
- * The bearer token returned at mint is short-lived and refreshed at the
4974
- * widget host; the session row is what makes revocation possible.
4977
+ * The browser renews short-lived bearer tokens at the widget host with
4978
+ * RenewWidgetSession, authenticated by its existing token. Renewal preserves
4979
+ * this bounded grant and does not extend its hard expiry.
4975
4980
  */
4976
4981
  export interface WidgetSession {
4977
4982
  metadata: OperationMetadata;
@@ -4988,6 +4993,45 @@ export interface WidgetSession {
4988
4993
  * headers server-side — never returned by any API.
4989
4994
  */
4990
4995
  secrets: Array<WidgetSession_Secret>;
4996
+ /**
4997
+ * Present only on creation. The same envelope is returned by
4998
+ * RenewWidgetSession on the widget host. Omitted on reads, lists, and revocation.
4999
+ * Existing spec.token/spec.token_expires_at and info.host remain populated
5000
+ * on creation for v1 compatibility and agree with these credentials.
5001
+ */
5002
+ credentials?: WidgetSessionCredentials;
5003
+ }
5004
+
5005
+ /**
5006
+ * WidgetSessionCredentials is the only credential envelope the customer's
5007
+ * backend forwards to the browser. Never log or persist its token. Responses
5008
+ * containing credentials use Cache-Control: no-store. Both initial and later
5009
+ * issuance use the same schema; no refresh token or management key is included.
5010
+ */
5011
+ export interface WidgetSessionCredentials {
5012
+ /**
5013
+ * Canonical wsess_ identifier. Ordinary renewal cannot change the session.
5014
+ */
5015
+ sessionId: string;
5016
+ /**
5017
+ * Authoritative hostname, without a scheme or path. Use HTTPS with this
5018
+ * host; never construct it or accept a host change during renewal.
5019
+ */
5020
+ host: string;
5021
+ /**
5022
+ * Short-lived bearer credential for the widget host only.
5023
+ */
5024
+ token: string;
5025
+ /**
5026
+ * Exact token expiry, at most 15 minutes after issuance and never later
5027
+ * than session_expires_at. Equals JWT exp without the 60-second validation
5028
+ * tolerance added. Renew proactively before this timestamp.
5029
+ */
5030
+ tokenExpiresAt: string;
5031
+ /**
5032
+ * Immutable hard session expiry. Issuance never extends this deadline.
5033
+ */
5034
+ sessionExpiresAt: string;
4991
5035
  }
4992
5036
 
4993
5037
  /**
@@ -5024,7 +5068,7 @@ export interface WidgetSessionInfo {
5024
5068
  messageCount: number;
5025
5069
  /**
5026
5070
  * When the session last created a conversation, sent a message, or
5027
- * refreshed a token.
5071
+ * received a newly issued token.
5028
5072
  */
5029
5073
  lastActiveAt?: string;
5030
5074
  }
@@ -5039,18 +5083,19 @@ export interface WidgetSessionSpec {
5039
5083
  */
5040
5084
  widgetId: string;
5041
5085
  /**
5042
- * Optional tenant assertion — the customer's org/company identifier for the
5043
- * visitor. Upserts the tenant record in the workspace and tags the session
5044
- * and every conversation it creates. Conversation listing at the widget
5045
- * host is scoped to this tenant.
5086
+ * Required tenant assertion — the customer's organization identifier.
5087
+ * Upserts the tenant record in the workspace. Every conversation created
5088
+ * through this session inherits the tenant and subject identity.
5046
5089
  */
5047
- tenant?: TenantAssertion;
5090
+ tenant: TenantAssertion;
5048
5091
  /**
5049
- * Optional subject assertion — the visitor within the tenant (e.g. their
5050
- * user id in the customer's namespace). Requires `tenant`; a subject
5051
- * asserted without a tenant is rejected with InvalidArgument.
5092
+ * Required subject assertion — the visitor's ID within the tenant.
5093
+ * Sessions with the same tenant and subject share conversation history on
5094
+ * the same widget and agent, subject to the current session's permissions.
5095
+ * A static ID deliberately shares that history; use a distinct ID per
5096
+ * visitor when their conversations should be separate.
5052
5097
  */
5053
- subject?: SubjectAssertion;
5098
+ subject: SubjectAssertion;
5054
5099
  /**
5055
5100
  * Hard session expiry. Tokens never outlive it; after it passes the session
5056
5101
  * transitions to STATE_EXPIRED. Defaults to a server-chosen horizon when
@@ -5058,14 +5103,14 @@ export interface WidgetSessionSpec {
5058
5103
  */
5059
5104
  expiresAt?: string;
5060
5105
  /**
5061
- * The session bearer token. Returned only on creation — subsequent reads
5062
- * omit it. The token is short-lived; the widget refreshes it at the widget
5063
- * host without involving the customer's backend.
5106
+ * Legacy creation-only alias of credentials.token; omitted on reads.
5107
+ * Supported throughout v1. New clients should consume credentials.
5108
+ * The browser obtains replacements with RenewWidgetSession at the widget host.
5064
5109
  */
5065
5110
  token: string;
5066
5111
  /**
5067
- * Expiry of the token returned in `token`. Distinct from `expires_at`,
5068
- * which bounds the session itself.
5112
+ * Legacy creation-only alias of credentials.token_expires_at, supported
5113
+ * throughout v1. Distinct from expires_at, which bounds the session itself.
5069
5114
  */
5070
5115
  tokenExpiresAt?: string;
5071
5116
  /**
@@ -5835,6 +5880,24 @@ export interface ModelSpec_Capability_Caching {
5835
5880
  caching: Capability_Caching;
5836
5881
  }
5837
5882
 
5883
+ /**
5884
+ * TOKEN_EXPIRED identifies access-token expiry beyond the 60-second clock-skew tolerance. That token cannot renew; use already-installed newer credentials or require explicit app reauthentication. SESSION_* reasons are terminal. Never infer renewability from HTTP status alone.
5885
+ */
5886
+ export type WidgetSessionErrorReason = 'TOKEN_EXPIRED' | 'SESSION_REVOKED' | 'SESSION_EXPIRED' | 'SESSION_EXHAUSTED';
5887
+
5888
+ /**
5889
+ * google.rpc.ErrorInfo detail for widget lifecycle failures. Match both domain and reason; ignore unknown reasons rather than renewing automatically.
5890
+ */
5891
+ export interface WidgetSessionErrorInfo {
5892
+ '@type': 'type.googleapis.com/google.rpc.ErrorInfo';
5893
+ domain: 'api.cadenya.com';
5894
+ reason: WidgetSessionErrorReason;
5895
+ /**
5896
+ * Optional non-sensitive context. Never contains tokens or secrets.
5897
+ */
5898
+ metadata?: Record<string, string>;
5899
+ }
5900
+
5838
5901
  export type AgentServiceListAgentsState = 'STATE_UNSPECIFIED' | 'STATE_DRAFT' | 'STATE_PUBLISHED' | 'STATE_ARCHIVED';
5839
5902
 
5840
5903
  export type AgentServiceListAgentsVariationSelectionMode = 'VARIATION_SELECTION_MODE_UNSPECIFIED' | 'VARIATION_SELECTION_MODE_RANDOM' | 'VARIATION_SELECTION_MODE_WEIGHTED';
@@ -5917,18 +5980,19 @@ export interface WidgetSessionSpecParam {
5917
5980
  */
5918
5981
  widgetId: string;
5919
5982
  /**
5920
- * Optional tenant assertion — the customer's org/company identifier for the
5921
- * visitor. Upserts the tenant record in the workspace and tags the session
5922
- * and every conversation it creates. Conversation listing at the widget
5923
- * host is scoped to this tenant.
5983
+ * Required tenant assertion — the customer's organization identifier.
5984
+ * Upserts the tenant record in the workspace. Every conversation created
5985
+ * through this session inherits the tenant and subject identity.
5924
5986
  */
5925
- tenant?: TenantAssertion;
5987
+ tenant: TenantAssertion;
5926
5988
  /**
5927
- * Optional subject assertion — the visitor within the tenant (e.g. their
5928
- * user id in the customer's namespace). Requires `tenant`; a subject
5929
- * asserted without a tenant is rejected with InvalidArgument.
5989
+ * Required subject assertion — the visitor's ID within the tenant.
5990
+ * Sessions with the same tenant and subject share conversation history on
5991
+ * the same widget and agent, subject to the current session's permissions.
5992
+ * A static ID deliberately shares that history; use a distinct ID per
5993
+ * visitor when their conversations should be separate.
5930
5994
  */
5931
- subject?: SubjectAssertion;
5995
+ subject: SubjectAssertion;
5932
5996
  /**
5933
5997
  * Hard session expiry. Tokens never outlive it; after it passes the session
5934
5998
  * transitions to STATE_EXPIRED. Defaults to a server-chosen horizon when